标签:SQ 连接 creates getc lag TE pre throws string
public class App { public static void main(String[] args) throws Exception { Class.forName("com.mysql.cj.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/vip?serverTimezone=GMT&useSSL=false", "root", "zhangpn"); Statement stat = conn.createStatement(); boolean flag = stat.execute("INSERT INTO `sys_user` VALUES (‘2‘, ‘0003‘, ‘bdmin‘, ‘123456‘)"); stat.close(); conn.close(); } }
同【JDBC连接数据库(查询)】相比,看出,整个过程重复的连接数据库;
所以,看以封装成一个工具类,专门获取连接,更专业的有数据库连接池:c3p0、dbcp等;
标签:SQ 连接 creates getc lag TE pre throws string
原文地址:https://www.cnblogs.com/batj/p/9215540.html