java.lang.ClassNotFoundException: com.mysql.jdbc.Driver comes up at Class.forName("com.mysql.jdbc.Driver").newInstance();

huangapple go评论95阅读模式
英文:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver comes up at Class.forName("com.mysql.jdbc.Driver").newInstance();

问题

Code:

            Class.forName("com.mysql.jdbc.Driver");

            mysql = new MySQL("localhost", 3306, "test", "root", "");
            MySQL.connect();

Exception:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:340)
	at me.veteranfighter.discordbot.Discordbot.main(Discordbot.java:30)

I also tried Class.forName("com.mysql.jdbc.Driver"); that didn't work either

I use Java 14 and have already implemented the MySQL connection jar.

Maybe someone can help. Would be very grateful...

英文:

Code:

            Class.forName("com.mysql.jdbc.Driver");

            mysql = new MySQL("localhost", 3306, "test", "root", "");
            MySQL.connect();

Exception:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:340)
	at me.veteranfighter.discordbot.Discordbot.main(Discordbot.java:30)

I also tried Class.forName("com.mysql.jdbc.Driver"); that didn't work either

I use java 14 and have already implemented the MySQL connection jar.

Maybe someone can help. Would be very grateful...

答案1

得分: 1

确保你的Classpath中有mysql-connector.jar。为了成功连接到MySQL数据库,"com.mysql.jdbc.Driver"必须存在于类路径中。

你可以从以下链接下载:
https://dev.mysql.com/downloads/connector/j/

英文:

make sure you've mysql-connector.jar in your Classpath. "com.mysql.jdbc.Driver" must be present in the classpath in order to successfully connect to MySQL database.

you can download from :-
https://dev.mysql.com/downloads/connector/j/

huangapple
  • 本文由 发表于 2020年8月16日 04:17:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63430458.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定