Java ClassNotFoundException:net.sourceforge.jtds.jdbc.Driver
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18658886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
提问by Dark Matter
I have java code which connects to a MS-SQL database and procures some data.
我有连接到 MS-SQL 数据库并获取一些数据的 java 代码。
Before running the code I set the class path in the Unix Server and it used to work fine.
在运行代码之前,我在 Unix 服务器中设置了类路径,它曾经工作正常。
But for some reason the same jar file which was working a few days back is throwing a Class not found exception java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
但由于某种原因,几天前还在工作的同一个 jar 文件抛出了一个 Class not found 异常java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
I have un-jared the jar file and found that the driver class which I'm loading :
我已经解压了 jar 文件,发现我正在加载的驱动程序类:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
is present in the specified package structure.
存在于指定的包结构中。
I don't understand how this is happening.
我不明白这是怎么回事。
Can anyone suggest any tips to resolve this.
任何人都可以建议任何提示来解决这个问题。
采纳答案by Shamim Ahmmed
The issue of java.lang.ClassNotFoundExceptionmight be the outcome of several reasons:
java.lang.ClassNotFoundException的问题可能是以下几个原因的结果:
Jar file is not available in class path. (This is not your case. as you have mentioned).
Your jar file is corrupted.
Your environment variable value is not accessible by current user. (Permission revoked by administrator).
Current user don't have permission to read jar file.
Jar 文件在类路径中不可用。(这不是你的情况。正如你所提到的)。
您的 jar 文件已损坏。
当前用户无法访问您的环境变量值。(权限被管理员撤销)。
当前用户无权读取 jar 文件。
Please verify the last three options.
请验证最后三个选项。
回答by Artur
Right button on project-> Properties - > Java built Path -> Order and Export -> And check checkBox with you jar.
项目上的右键-> 属性-> Java 构建路径-> 订购和导出-> 并用您的jar 选中复选框。
If you connect on Android project to Use 1.2.7 version.
如果您在 Android 项目上连接到使用 1.2.7 版本。
回答by nsthethunderbolt
I know it's late, but for others facing the same problem..
我知道已经晚了,但对于其他面临同样问题的人..
If you are using eclipse:
1. Go to Project -> Properties -> Java Build Path -> Order and export.. and check the jar file for jtds.version.jar
2. Go to Run Configurations and add this jar file to the user defined jars.
Hope this helps..:)
如果您使用的是 eclipse:
1. 转到 Project -> Properties -> Java Build Path -> Order and export.. 并检查 jtds.version.jar 的 jar 文件
2. 转到 Run Configurations 并将此 jar 文件添加到用户定义的罐子。
希望这可以帮助..:)