Java:Netbeans - 没有找到适合 jdbc mysql 的驱动程序(在构建和清理项目之后)

发布于 2024-10-09 22:32:03 字数 276 浏览 0 评论 0原文

在 Netbeans 中,我在项目中选择了“构建和清理”选项,但是如果我从 /dist 文件夹中移动 .jar 文件,则会收到此错误:
“错误:找不到适合‘我的数据库网址’的驱动程序”

现在我知道数据库连接可以正常工作,因为当我在 netbeans 中运行该项目时,如果我离开,我可以检索数据并将其输入到数据库中/dist 文件夹中的 .jar 文件可以正常工作。无论如何,我可以在构建项目时包含驱动程序吗?
如果这没有意义,请随时告诉我,我会尽力详细说明。
非常感谢任何帮助。

In Netbeans I've selected the 'build and clean' option on my project, however if I move the .jar file from the /dist folder, I get this error:
"Error: not suitable driver found for 'my database url here'"

Now I know that the database connection works because when I run the project in netbeans I'm able to retrieve and input data into the database, if I leave the .jar file in the /dist folder it works with no problems. Is there anyway I can include drivers when building the project?
Feel free to tell me if this makes no sense and I'll try my best to elaborate.
Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人事已非 2024-10-16 22:32:03

更新

这里的问题是您的 netbeans 不包含构建中所需的驱动,而是从 dist 中的 lib 目录引用它

来终止此

goto netbeans 项目 > build.xml

之前的

 <target name="-pre-jar">
    <unjar src="${file.reference.quartz-1.5.2.jar}" dest="${build.classes.dir}"/>
</target>

添加此注意:quartz-1.5.2.jar 将由您的项目 file.reference.quartz-1.5.2 引用。罐
您可以从您的 project.properties 文件中获取此类指针,尝试找到 jdbc jar 的指针和所有必需的内容,然后添加,这样它就可以工作了。

从任何地方清理、构建和运行它。它将包含外部库到构建中

Update

The problem here is your netbeans doesn't include required drived in build instead it is referring it from lib dir in dist

to kill this

goto netbeans project > build.xml

before </project> add this

 <target name="-pre-jar">
    <unjar src="${file.reference.quartz-1.5.2.jar}" dest="${build.classes.dir}"/>
</target>

Note: quartz-1.5.2.jar will be referred by your project file.reference.quartz-1.5.2.jar
You can get such pointers from your project.properties file try to find jdbc jar's pointer and all required and add then this way it will work.

clean and build and run it from anywhere. it will include external libraries into build

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文