1:获得连接(两个对象 DriverManager和 DataSource)
DriverManager.getConnection这里需要数据库的URL
2:创建声明(1执行简单的查询, 2执行需要输入的查询, 3执行调用存储过程的有输入和输出的查询)
3: execute(当得到一个ResultSet对象的时候返回真,利用
getResultSet可以检索数据).
executeQuery
: Returns one ResultSet
object.
executeUpdate
: Returns an integer representing the number of rows affected by the SQL statement. Use this method if you are using INSERT
, DELETE
, orUPDATE
SQL statements.
4:处理ResultSet对象
5:关闭连接
转载于:https://blog.51cto.com/3386285/847111