Update database version in Java existing project. Yes, If the database version is updated then We have to make some changes to the project as well, mainly the database depends on “database version”, “Connection URL”, “database versions” and “port number”.
In this Java web project error-solving tutorial, Let’s cover all the above points one by one to update the database version in a java web project. For the demo, this example is using the MYSQL database.
Find MySQL version.
We can verify the database server versions from MySQL workbench and also from MYSQL CMD.
Check MYSQL server version in workbench
Go to Server ==> Server Status ==> “Check the port number and MySQL database versions”.
CMD Command to check MySQL version
select @@version;
Update maven dependencies in Pom.xml.
Open pom.xml file, Check the maven dependencies for “Java MySQL connection”. Update the dependencies with a similar version of the database sever.
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.15</version> </dependency>
Update Driver Name
Always verify the database driver name, sometimes we have to update the driver name as well for example before MySQL v8 the driver name was com.mysql.jdbc.Driver
and after MySQL v8 the driver name is com.mysql.jdbc.Driver
Update Connection URL, Database Username, and Password.
Verify the port number and database name into your connection URL “jdbc:mysql://localhost:3306/databasename”, here 3306 is port number and “databasename “ is the name of the database.
Verify the database username and password.
jdbc:mysql://localhost:3306/databasename
Update connection URL as per TimeZone
"jdbc:mysql://localhost/mydb?useLegacyDatetimeCode=false&serverTimezone=America/New_York"
Update Maven Project
- Right-click on the project ==> Maven ==> Update project.
- Check force update of snapshots/Release option.
- Click to OK.