时间:2021-07-01 10:21:17 帮助过:35人阅读
1.加载驱动
Class.forName(driver_class);
2.创建数据库连接
DriverManager.getConnection(url,user,password);
3.创建PreparedStatement
PreparedStatement ps=connection.prepareStatement(sql);
4.执行sql语句
rs=ps.executeQuery();
5.处理结果集
while (rs.next()){
rs.getObject();
}
6关闭连接(资源从内由外关闭)
/从内到外关闭
if (resultSet!=null){
resultSet.close();
}
if (preparedStatement!=null){
preparedStatement.close();
}
if (connection!=null){
connection.close();
}
JDBC
标签:resultset name ext set jdbc statement query tco manager