将 jdbc 驱动程序添加到类路径 [英] Adding jdbc driver to classpath

查看:51
本文介绍了将 jdbc 驱动程序添加到类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我使用的是 Win Vista 并正确设置了我的 MAVEN_HOME、JAVA_HOME 内容.但我还没有课程路径.我也安装了 MySQL.现在我打开了一本 Hibernate 书,在第一页上写着确保 jdbc 驱动程序在您的类路径中".我还下载了一些 Zip 文件,它是 ConnectorJ 或类似的名称,它基本上是 java 的 mySql 驱动程序......但我现在的问题是这句话,我不知道如何去做:确保 jdbc 驱动程序在你的类路径中"你能帮我解决这个类路径的问题吗?

Ok I am on Win Vista and correctly set my MAVEN_HOME, JAVA_HOME stuff. but I do not have a class path yet. I have also installed MySQL. now I have opened a Hibernate book and at the very first pages it says "make sure the jdbc driver is in your classpath" . I have also downloaded some Zip file that is ConnectorJ or some name like that which is basically the mySql driver for java... but my problem for now is this sentence that I have no clue how to do it: "make sure the jdbc driver is in your classpath" would you please help me about this classpath thing?

谢谢

推荐答案

Here is a good tutorial about, 设置类路径.此外,您可能还想阅读管理 Java 类路径 (Windows).

Here is a good tutorial regarding, setting the class path. Further you might like to read Managing the Java classpath (Windows).

话虽如此,您不应该在 Windows 环境变量中为您的驱动程序设置类路径.相反,您应该在项目属性下的 IDE 中包含该驱动程序 jar.但我注意到您实际上正在使用 Maven.在这种情况下,您应该在 Maven 下查找驱动程序以实现该依赖项.Maven 将下载驱动程序 jar,如果不存在,并将其设为本地.

Having said that, you should not set the classpath for your driver in Windows environment variable. Instead, you should include that driver jar inside your IDE under project properties. But I noticed that you are actually using Maven. In this case you should look for the driver under Maven in order to fulfil that dependency. Maven will download the driver jar, if doesn't exist, and make it local.

如果你没有使用任何 IDE,那么你可以创建一个 lib 目录并告诉编译器所有需要的 jar 都在那里,当时编译/执行.您可以在上面给出的前一个链接中找到 HOW.

In case, you are not using any IDE, then you can create a lib directory and tell the compiler that all required jars are in there, at the time of compilation/execution. You can find HOW, in the former link given above.

这篇关于将 jdbc 驱动程序添加到类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆