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:關閉連接