1)載入(註冊)資料庫驅動(到jvm)。
2)建立(獲取)資料庫連線。
3)建立(獲取)資料庫操作物件。
4)定義操作的sql語句。
5)執行資料庫操作。
6)獲取並操作結果集。
7)關閉物件,**資料庫資源(關閉結果集-->關閉資料庫操作物件-->關閉連線)。
public class jdbctest
} catch (exception e) finally catch (sqlexception e)
} if (stmt != null) catch (sqlexception e)
} if (conn != null)
} catch (sqlexception e)
} }
} }
JDBC連線的幾個步驟
每次都會執行sql語句,相關資料庫都要執行sql語句的編譯。statement為一條sql語句生成執行計畫,如果要執行兩條sql語句 select colume from table where colume 1 select colume from table where colume 2 會生成...
JDBC資料庫連線步驟
1 載入資料庫驅動 class.forname com.mysql.jdbc.driver 2 建立資料庫連線池 conn drivermanager.getconnection jdbc mysql localhost 3306 test2?user root password 1234 3 由當...
jdbc資料庫連線步驟
筆記 連線資料庫的幾大步驟 1.載入驅動 class.forname 資料庫驅動的名稱 2.建立連線 connection conn driver.getconnection 路徑 使用者名稱 密碼 埠號 3.建立預編譯物件 statement stat conn.createstatement 4...