Determine the SQL Server JDBC version on command line Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Determine the SQL Server JDBC version on command line without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have several servers which use the Microsoft SQL Server JDBC driver. The files are all named sqljdbc4.jar. I need to know what version of the driver each one contains. Time stamps and file sizes are not helpful, as I need to extract the driver version number. I need to be able to run this on the command line.

I have seen for DB2 you can run this command and get the version:

java -cp ./db2jcc.jar com.ibm.db2.jcc.DB2Jcc -version

What is the equivalent, if any, for Microsoft SQL Server?

Answer

It seems that there is no dedicated CLI to print out the driver version but you can ask the MS 4.x driver for its version:

import java.sql.Driver;
import com.microsoft.sqlserver.jdbc.SQLServerDriver;
...
Driver driver = new SQLServerDriver();
driver.getMajorVersion();  // -> 4
driver.getMinorVersion();  // -> 0, 1, 2, ...

You could build a simple commandline wrapper to print out this information.

We are here to answer your question about Determine the SQL Server JDBC version on command line - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji