java链接数据库的方法?
代码是网上找的没怎么看懂,请大神指点public class TestJDBC {
public static Connection getSQLConnection() throws SQLException,java.lang.ClassNotFoundException{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/learn";
String userName = "root";
String password = "123456";
Connection con = DriverManager.getConnection(url,userName,password);
return con;
}
public static void main(String[] args) {
try{
Connection con = getSQLConnection();
Statement sql = con.createStatement();
jdbc就可以了 https://www.cnblogs.com/hongten/archive/2011/03/29/1998311.html 可以参考下 jdbc直接参数连接 jdbc连接, 参考http://www.cnblogs.com/hongten/archive/2011/03/29/1998311.html jdkc直接连接
页:
[1]