同质光波导
1. Go to https://dev.mysql.com/downloads/connector/j/, get the latest version of Connector/J
2. Remember to set the classpath to include the path of the connector jar file.
If we don't set it correctly, below errors can occur:
No suitable driver found for jdbc:mysql://127.0.0.1:3306/msystem_development
java.lang.ClassNotFoundException: com.mysql.jdbc:Driver
方法1:设置类路径变量。
export CLASSPATH=".:mysql-connector-java-VERSION.jar"
java MyClassFile
在上面的命令中,我将类路径设置为当前文件夹和mysql-connector-java-VERSION.jar文件。所以当
java MyClassFile
命令执行后,java应用程序启动程序将尝试在类路径中加载所有java类。
它发现了
Drive
class=>BOOM错误已消失。
方法2:
java -cp .:mysql-connector-java-VERSION.jar MyClassFile
注意:Class.forName(“com.mysql.jdbc.Driver”);这在2019年4月的这个时候是不推荐的。
希望这能帮助别人!