Analysis of the differences between several jars when using Java to connect to sqlserver databases

  • 2020-04-01 03:29:48
  • OfStack

Today, I saw someone ask this question in the group, so I would like to share the knowledge I have summed up with you. Of course, there may be something wrong, and I wish to point out that:

***msbase.jar, mssqlserver.jar, msutil. Jar (support sql2000):

Early connection database jars: you had to manually import the driver package when connecting data. Manually import class.forname (driver name);

***SQL Server JDBC Driver 2.0-- sqljdbc.jar and sqljdb44.jar

The new JDBC connection database Jar package supports sql2005, sql2008

Sqljdbc. Jar

When using the sqljdbc.jar class library, the application must first register the driver by class.forname. Jdk1.6 or above is not recommended.

Sqljdbc4. Jar

In the JDBC API 4.0, DriverManager. GetConnection method has been enhanced, can automatically load the JDBC Driver. Therefore, when using the sqljdb44.jar Class library, the application does not need to call the class.forname method to register or load the driver. When the getConnection method of the DriverManager class is called, the Driver is found from the registered JDBC Driver set. Sqljdbc4. Jar file including the meta-inf/services/Java. SQL. Driver "file, which contains. Essentially, JDBC. SQLServerDriver as registered Driver. The existing application, which currently loads the driver by using the class.forname method, will continue to work without modification.

Note: the sqljdb44.jar class library requires a Java runtime environment (JRE) of 6.0 or later.


Related articles: