首先,您需要在连接之前加载JDBC驱动程序
// Notice, do not import com.mysql.jdbc.*// or you will have problems!//Load Drivertry { // 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");运行应用程序时,请确保在类路径上具有mysql-connector-java-5.xx-bin.jar。



