What files needed for JDBC connection to MySQL?
I get the following error when attempting to connect to the MySQL database on my employer's local server:
Unable to load database driver Details : java.lang.ClassNotFoundException: com.mysql.jdbc.Driver BUILD SUCCESSFUL (total time: 0 seconds)
I think it's pretty clear that this is because I don't have my files set up properly. Only problem is, I don't know what I need, and where it needs to go. Is the Driver a .class file? Where can I download 开发者_如何转开发it? Where in my filesystem (ubuntu, fwiw) do I put the file so that "Class.forName("com.mysql.jdbc.Driver").newInstance();" works?
Thanks for all your help, m8s.
Yes, it is a .class
file that uses a others .class
files. You call all these collections of files, a library and in this particular case, the library is also named: "jdbc driver".
These libraries are usually .jar
files, so in your case you may try:
http://www.mysql.com/products/connector/j/
To download the MySQL JDBC driver.
You should put it in your classpath
You can download the connector here (the .jar you need is inside the .zip/.tar.gz):
http://dev.mysql.com/downloads/connector/j/
The .jar needs to be in a classpath available to your application.
精彩评论