[英]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 . 我开发了一个程序,可从远程sql服务器提取数据并将其推送到本地mysql服务器。为此我导出了一个jar文件。
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 . 现在我试图在另一台机器上运行这个jar文件来完成相同的任务。所有IP和端口都进行了相应的更改。这台机器上没有IDE。
When i am running this jar file , i get an error saying "No suitable driver found for jdbc:sqlserver:/ 172 . * " 当我运行此jar文件时,出现错误消息“找不到适合的jdbc:sqlserver:/ 172驱动程序。 * ”
I have installed the jdbc driver in program files . 我已经在程序文件中安装了jdbc驱动程序。
So what do i have to do to run this jar file . 所以,我要怎么做才能运行这个jar文件。
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).
一种直接的方法是将其导出为jar中的依赖项(尽管可能存在许可问题)。
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. 运行Java程序所需的全部是Java可执行文件,类文件或压缩/压缩的类文件以及类文件所需的其他文件。 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 ';'
因此,第一步是找到您的Java可执行文件,也许是c:\\ java.exe或/ home / yourhome / java,第二步是收集所有类或zip / jar归档文件,并将它们放入在Unix上用':'分隔的字符串中或类Unix或';' 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. 最后,使用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. 忘记有关“安装”程序或驱动程序的任何内容,只需将其中的一些内容放入系统的类路径或路径或类似的内容中即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.