JDBC 程序中的 java.lang.ClassNotFoundException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19179687/
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
java.lang.ClassNotFoundException in JDBC program
提问by Rajendra arora
I'm making a simple JDBC program in java SE 7 but after compiling program it's giving "java.lang.ClassNotFoundException: org.postgreasql.Driver" error i followed this link http://docs.oracle.com/javase/7/docs/technotes/guides/jdbc/but not getting yet so please help.
我正在 Java SE 7 中制作一个简单的 JDBC 程序,但在编译程序后它给出了“java.lang.ClassNotFoundException: org.postgreasql.Driver”错误我按照这个链接http://docs.oracle.com/javase/7/ docs/technotes/guides/jdbc/但还没有得到所以请帮忙。
采纳答案by SpringLearner
possibly you may not be setting the path of jdbc driver follow the steps
可能你没有设置 jdbc 驱动程序的路径,请按照以下步骤操作
- Right click on your project
- click buildpath->configure Build Path
- click libraries tab
- Click add external jars and give the path of driver
- 右键单击您的项目
- 点击构建路径->配置构建路径
- 单击库选项卡
- 点击添加外部罐子并给出驱动程序的路径
回答by frederikdebacker
THe name of the driver is wrong also. Should be org.postgresql.Driver iso org.postgreasql.Driver. So maybe a typo in your java code where you do Class.forname()
司机的名字也错了。应该是 org.postgresql.Driver iso org.postgreasql.Driver。因此,您在执行 Class.forname() 的 Java 代码中可能存在拼写错误
回答by Husam
回答by istovatis
You have to add the jdbc jar file on your build path. Firstly you have to download the jar from the link you provided. Then add it to build path. If you use eclipse: Right click on your project at the package explorer->Configure Build Path->Libraries->Add external jar->select your jar.
您必须在构建路径上添加 jdbc jar 文件。首先,您必须从您提供的链接下载 jar。然后将其添加到构建路径。如果您使用 eclipse:在包资源管理器中右键单击您的项目-> 配置构建路径-> 库-> 添加外部 jar-> 选择您的 jar。
回答by Iren Patel
Please check your connection String url or connection driver and run code.
请检查您的连接字符串 url 或连接驱动程序并运行代码。
回答by Brian Agnew
This:
这个:
org.postgreasql.Driver
should likely be
应该是
org.postgresql.Driver