简体   繁体   中英

MySQL JDBC: no suitable driver found

I have developed a program that pulls the data from a remote sql server and pushes it to local mysql server .I have a jar file exported for this .

Now I am trying to run this jar file on different machine to do the same task .All the IP's and ports have been changed accordingly .There is no IDE on this machine .

When i am running this jar file , i get an error saying "No suitable driver found for jdbc:sqlserver:/ 172 . * "

I have installed the jdbc driver in program files .

So what do i have to do to run this jar file .

You need to add the library to the runtime classpath. A straightforward way would be to export it as a dependency in the jar (although there might be licencing issues with that).

How are you creating the jar?

在您的类路径中而不是在“程序文件”中添加jdbc驱动程序。...检查JVM的文档http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

All you need to run a Java program is a Java executable and class files or zipped/jared class files and other files needed by class files. So 1st step is locate your java executable, maybe c:\\java.exe or /home/yourhome/java, and 2nd step is gather all your classes or zip/jar archive and put them in a String split by ':' on Unix or Unix-like or ';' on windows. 3rd step is to identify your main class, which is the only entry of your program.

In the end, use YOUR_JAVA_EXECYTABLE -classpath YOUR_CLASS_PATH YOUR_MAIN_CLASS. works fine for most scenarios.

Forget anything about "installed" a program or driver, which is just put some some in system's classpath or path or anything like this.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM