JDBC四要素:
a1.driver: 驱动字符串
a2.url:连接数据库的字符串
a3.user:数据库的用户名
a4.pwd:密码
JDBC常用的类和接口:
1.DriverManager类:驱动管理类
Connection con = DriverManager.getConnection(url,username,pwd);
**2.Connection接口:**数据库连接的接口
Statement stmt = con.createStatement();
PreparedStatement ps = con.prepareStatment(sql);
con.setAutocommit(true|false);//是否自动提交
con.commit();//提交事务
con.rollback(); //回滚事务
con.close();//关闭资源
**3.Statement和PreparedStatement接口:**向数据库发送sql语句,执行sql,执行后的结果返回
Statement stmt = con.createStatement();
a1.boolean flag = stmt.execute(sql);//执行sql命令的方法 select,insert,delete,update
a2.ResultSet rs = stmt.executeQuery(“select * from student”);//执行查询
a3.int count = stmt.executeUpdate(sql); //执行insert,delete,update
4.PreparedStatement子接口
Stri