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

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

问题描述

好吧,我在Win Vista上正确设置了我的MAVEN_HOME,JAVA_HOME的东西。但我还没有课程路径。我也安装了MySQL。现在我已经打开了一本Hibernate书,并在第一页说确保jdbc驱动程序在您的类路径中。我也下载了一些Zip文件,它们是ConnectorJ或者一些类似于java的mySql驱动程序的名称......但是现在我的问题是这句话,我不知道该怎么做:确保jdbc驱动程序在你的类路径中
你能帮我介绍一下这个类路径吗?



谢谢 href =http://docs.oracle.com/javase/tutorial/essential/environment/paths.html =nofollow>设置类路径。此外,您可能想阅读管理Java类路径(Windows)

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



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


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?

thanks

解决方案

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

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.

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天全站免登陆