public class JdbcTools {
private static Connection con;
private static String url;
private static String user;
private static String pwd;
public static Connection getConnection(){
//第一步加载驱动
try {
Class.forName("org.gjt.mm.mysql.Driver");
url = "jdbc:mysql://localhost:3306/119";
user = "root";
pwd = "123";
//第二步创建连接
con = (Connection) DriverManager.getConnection(url, user, pwd);
con.setAutoCommit(false);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
}