开发者

Getting MySQL Connector/J + JDBC to work

开发者 https://www.devze.com 2023-04-13 04:16 出处:网络
I\'ve been trying to get MySQL Connector/J set up for the past hour but I am not getting anywhere. I tried following a lot of tutorials, and am using the code on this page to test my connection:

I've been trying to get MySQL Connector/J set up for the past hour but I am not getting anywhere.

I tried following a lot of tutorials, and am using the code on this page to test my connection:

http://www.stardeveloper.com/articles/display.html?article=2003090201&page=4

I have tried putting the path to the connector .jar file in the CLASSPATH environment variable, but that didn't get me anywhere. I also tried putting it in %JAVA_HOME%/jre/lib/ext and it STILL doesn't work??

When I run the code that 开发者_JAVA技巧is provided on that page, I get the following error which isn't very useful.

Exception: com.mysql.jdbc.Driver

I feel like it isn't finding the jar file but I have no idea what else to do.

I don't know if it is worth mentioning, but I installed MySQL through XAMPP.

Thanks for any help!


If you can use Eclipse, adding a MySQL jar to the classpath is 1, 2, 3 => three clicks

Otherwise, when you run your application you can add jar(s) to the classpath using a -cp option:

java -cp mysql.jar MySqlExample.java

You can follow this simple example on how to get Java and MySQL talk to each other.

0

精彩评论

暂无评论...
验证码 换一张
取 消