常見資料庫連線方式

2021-08-03 22:55:44 字數 2278 閱讀 3191

記下來以留著以後忘記了檢視

mysql:

1      string driver="com.mysql.jdbc.driver";    //

驅動程式

2 string url="jdbc:mysql://localhost:3306/db_name"; //

連線的url,db_name為資料庫名

3 string username="username"; //

使用者名稱

4 string password="password"; //

密碼

5class.forname(driver);

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

oracle:

1      string driver="oracle.jdbc.driver.oracledriver";    //

連線資料庫的方法

2 string url="jdbc:oracle:thin:@loaclhost:1521:orcl"; //

orcl為資料庫的sid

3 string username="username"; //

使用者名稱

4 string password="password"; //

密碼

5 class.forname(driver) ; //

載入資料庫驅動

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

postgresql:

1  string driver="org.postgresql.driver";    //

連線資料庫的方法

2 string url="jdbc:postgresql://localhost/db_name"; //

db_name為資料庫名

3 string username="username"; //

使用者名稱

4 string password="password"; //

密碼

5class.forname(driver) ;

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

db2:

連線具有db2客戶端的provider例項 2//

string driver="com.ibm.dbjdbc.net.dbdriver";

//連線不具有db2客戶端的provider例項

3 string url="jdbc:db2://localhost:5000/db_name"; //

db_name為資料庫名

4 string username="username"; //

使用者名稱

5 string password="password"; //

密碼

6 class.forname(driver) ;

microsoft sql server :

1   string driver="com.microsoft.sqlserver.jdbc.sqlserverdriver";    //

連線sql資料庫的方法

2 string url="jdbc:sqlserver://localhost:1433;databasename=db_name"; //

db_name為資料庫名

3 string username="username"; //

使用者名稱

4 string password="password"; //

密碼

5 class.forname(driver).new instance(); //

載入資料可驅動

常見資料庫連線方式

記下來以留著以後忘記了檢視 mysql 1 string driver com.mysql.jdbc.driver 驅動程式 2 string url jdbc mysql localhost 3306 db name 連線的url,db name為資料庫名 3 string username us...

常見資料庫使用JDBC連線方式

1 oracle8 8i 9i資料庫 thin模式 class.forname oracle.jdbc.driver.oracledriver newinstance string url jdbc oracle thin localhost 1521 orcl orcl為資料庫的sid strin...

常見資料庫比較

一 開放性1.sql server 只能在windows上執行,沒有絲毫的開放性,作業系統的系統的穩定對資料庫是十分重要的。windows9x系列產品是偏重於桌面應用,nt server只適合中小型企業。而且windows平台的可靠性,安全性和伸縮性是非常有限的。它不象unix那樣久經考驗,尤其是在...