鏈結資料庫的基本步驟

2021-08-13 09:03:07 字數 709 閱讀 9721

基本步驟:

準備鏈結資料庫引數 鏈結資料庫引數,賬號和密碼

資料庫位址url

* 載入驅動private static string driver="com.mysql.jdbc.driver";

class.forname(driver);

* 獲得資料庫連線2種

* 1獲得自動提交事務的鏈結

con = drivermanager.getconnection(url, username, password);

* 建立狀態通道

sta = con.createstatement();

* 基於狀態通道的查詢

rs = sta.executequery(sql);

* 基於狀態通道的修改

* 建立預裝他態通道

psta = con.preparestatement(sql);//sql不完整,通過引數傳

* 基於預狀態通道的查詢

* 基於預狀態通道的修改

* 2.獲得手動提交事務的的鏈結

con.setautocommit(false);

*建立狀態通道

*基於狀態通道的查詢

*基於狀態通道的修改

*建立預狀態通道

*基於預狀態通道的查詢

*基於預狀態通道的修改

*提交事務的方法

*回滾事務的方法

*關閉資源

建立資料庫鏈結(dblink)步驟

1.create database link資料庫鏈結名connect to 使用者名稱 identified by 密碼 using 資料庫連線字串 可以像這樣 create database link orcl2 connect to user identified bypwd using de...

建立資料庫鏈結(dblink)步驟

1.create database link資料庫鏈結名connect to 使用者名稱 identified by 密碼 using 資料庫連線字串 可以像這樣 create database link orcl2 connect to user identified bypwd using de...

資料庫設計的基本步驟

資料庫設計的基本步驟 1 需求分析階段 需求收集和分析,得到資料字典和資料流圖。2 概念結構設計階段 對使用者需求綜合 歸納與抽象,形成概念模型,用e r圖表示。3 邏輯結構設計階段 將概念結構轉換為某個dbms所支援的資料模型。4 資料庫物理設計階段 為邏輯資料模型選取乙個最適合應用環境的物理結構...