JDBC
jdbc全称是Java DataBase Connectivity,是一套定义好的API,由各个数据库厂商根据JDBC定义的API自己去实现相应的数据库驱动
JDBC的使用
- 加载相应数据库的jdbc驱动
- 获取数据库连接
- 通过连接对象创建Statement对象
- 通过Statement对象执行SQL语句
- 操作结果集
- 回收数据库资源
//***
Class.forName(driver);
try{
Connection conn = DriverManager.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.execute() \ stmt.executeUpdate() \ stmt.executeQuery();
//***
// 对rs进行操作
//***
}
//***