JDBCUtilsToos
public static Connection getconn() {
Connection conn=null;
// 注册驱动
try {
Class.forName("com.mysql.jdbc.Driver");
// 获取链接对象
String url = ("jdbc:mysql://localhost:3306/demo1127?characterEncoding=UTF-8");
String user = "root";
String pwd = "123456";
conn = DriverManager.getConnection(url, user, pwd);(鼠标移上去点第三个)
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
// 增删改释放资源方法
public static void close(Connection conn, PreparedStatement pst){
if(pst!=null){
pst.close();点出try
}
if(conn!=null){
conn.close();点出try
}
}