DriverManager no suitable driver mysql

有些话、适合烂在心里 提交于 2019-12-06 07:35:30

First you need to load JDBC driver before connection

// Notice, do not import com.mysql.jdbc.*
// or you will have problems!

//Load Driver
try {
  // The newInstance() call is a work around for some
  // broken Java implementations
  Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
  // handle the error
}

con=DriverManager.getConnection(connectieString);
System.out.println ("Database connection established");

make sure you have mysql-connector-java-5.x.x-bin.jar on the classpath when you run your application.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!