英文:
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/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论