0

I wonder if there is easy way to replace jdbc4 library to mysql-connector-java lib in project, and what are the differences in code

Thanks for answers :)

(I'm doing it because there is no jdbc4 lib in maven repository )

MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125

1 Answers1

1

If you are talking about "jdbc4", you are probably talking about the sqljdbc4.jar of the Microsoft SQL Server JDBC Driver. You can't just replace the SQL Server JDBC Driver with the MySQL Connector/J JDBC driver: they aren't for the same server; it would also mean replace your database and maybe rewrite some incompatible queries, and if you have used some driver-specific extensions, it would also mean rewriting those parts of your code.

Instead you should add the SQL Server driver to your local maven repository (or to your companies maven repository). See for example maven dependency for sqlserver2010?

Another option would be to specify the dependency to the driver with a systemPath to the driver local to your project (but that has some downsides).

Since a few years above suggestions for putting the dependency in a local repository or using systemPath is no longer necessary, as the driver is now in Maven Central with coordinates com.microsoft.sqlserver:mssql-jdbc.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • I'm confused, what about JDBC4 implied MS SQL? – dlamblin Mar 23 '21 at 22:28
  • @dlamblin At that time, the only driver I knew that had jdbc4 (or something close to that) in a driver JAR name (or in the name of its download package) was the Microsoft SQL Server JDBC driver (it had `sqljdbc.jar` for JDBC 3 and `sqljdbc4.jar` for JDBC 4). I added that in my answer for clarification – Mark Rotteveel Mar 24 '21 at 09:04