I want my java application to use jdbc 7.4.1 version. After researching, I found overriding classpath is one way to do it. But I am getting below error.
Environment: RHEL
override classpath
java -cp /home/xyz/sqljdbc_7.4/enu/mssql-jdbc-7.4.1.jre8.jar com.microsoft.sqlserver.jdbc.SQLServerDriver
Error
Error: Main method not found in class com.microsoft.sqlserver.jdbc.SQLServerDriver, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
Question: Is this the right way to do it or there are other/better ways to accomplish the same thing? Secondly, how to resolve the error I am getting?
With the line
java -cp /home/xyz/sqljdbc_7.4/enu/mssql-jdbc-7.4.1.jre8.jar com.microsoft.sqlserver.jdbc.SQLServerDriver
you are executing the class com.microsoft.sqlserver.jdbc.SQLServerDriver
with class path set to /home/xyz/sqljdbc_7.4/enu/mssql-jdbc-7.4.1.jre8.jar
That's the reason why you getting the error given above. Because jvm tries to find the main entry point (public static void main()) in the jar com.microsoft.sqlserver.jdbc.SQLServerDriver. I guess you want to set both jars in class path and execute your own programm. The you have to call it that way:
java -cp .:/home/xyz/sqljdbc_7.4/enu/mssql-jdbc-7.4.1.jre8.jar:com.microsoft.sqlserver.jdbc.SQLServerDriver <place your jarfile here>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.