连接数据库的步骤
//1.加载驱动
Class.forName("com.mysql.jdbc.Driver");
//2.获得连接对象
Connection conn=DriverManager.getConnection(url, user, password);
//3.获取Statement对象
Statement stmt=conn.createStatement();
//执行sql语句
stmt.executeUpdate(sql);
//关闭资源
stmt.close();
conn.close();
浙公网安备 33010602011771号