时间:2021-07-01 10:21:17 帮助过:22人阅读
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBConnection { private static final String name = "root"; private static final String pass = ""; public static Connection ConnectDB() { Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mytestdb", name, pass); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return con; } }
java 连接 mysql
标签:java mysql