jdbc 數(shù)據(jù)庫(kù)的連接(sqlserver oracle)
更新時(shí)間:2009年08月05日 23:00:48 作者:
sql Server 和oracle 數(shù)據(jù)庫(kù)的連接,供大家參考!
1.sql server 2000數(shù)據(jù)庫(kù)的連接方式:
Connection con;
public Connection getCon(){
try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");//加載驅(qū)動(dòng)程序
con=DriverManger.getConnection("jdbc:microsoft:sqlServer://localhost:1433;DatabaseName=aa","sa",""); // 試圖建立到給定數(shù)據(jù)庫(kù) URL 的連接
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
return con;
}
2.sql server 2005數(shù)據(jù)庫(kù)的連接方式:
Connection con;
public Connection getCon(){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");//加載驅(qū)動(dòng)程序
con=DriverManger.getConnection("jdbc:microsoft:sqlServer://localhost:1433;DatabaseName=aa","sa",""); // 試圖建立到給定數(shù)據(jù)庫(kù) URL 的連接
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
return con;
}
3.oracle 數(shù)據(jù)的連接方式
Connection con;
public Connection getCon(){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManger.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:oracle","scott","tiger");
}catch(Exception e){
e.printStackTrace();
}
return con;
}
復(fù)制代碼 代碼如下:
Connection con;
public Connection getCon(){
try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");//加載驅(qū)動(dòng)程序
con=DriverManger.getConnection("jdbc:microsoft:sqlServer://localhost:1433;DatabaseName=aa","sa",""); // 試圖建立到給定數(shù)據(jù)庫(kù) URL 的連接
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
return con;
}
2.sql server 2005數(shù)據(jù)庫(kù)的連接方式:
復(fù)制代碼 代碼如下:
Connection con;
public Connection getCon(){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");//加載驅(qū)動(dòng)程序
con=DriverManger.getConnection("jdbc:microsoft:sqlServer://localhost:1433;DatabaseName=aa","sa",""); // 試圖建立到給定數(shù)據(jù)庫(kù) URL 的連接
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
return con;
}
3.oracle 數(shù)據(jù)的連接方式
復(fù)制代碼 代碼如下:
Connection con;
public Connection getCon(){
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManger.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:oracle","scott","tiger");
}catch(Exception e){
e.printStackTrace();
}
return con;
}
相關(guān)文章
DBeaver之如何導(dǎo)出數(shù)據(jù)庫(kù)結(jié)構(gòu)和數(shù)據(jù)
這篇文章主要介紹了DBeaver之如何導(dǎo)出數(shù)據(jù)庫(kù)結(jié)構(gòu)和數(shù)據(jù)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04datagrip如何找到數(shù)據(jù)庫(kù)和表
這篇文章主要介紹了datagrip入坑指南(如何找到數(shù)據(jù)庫(kù)和表)的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2020-09-09mysql、mssql及oracle分頁(yè)查詢方法詳解
這篇文章主要介紹了mysql、mssql及oracle分頁(yè)查詢方法,實(shí)例分析了數(shù)據(jù)庫(kù)分頁(yè)的實(shí)現(xiàn)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04利用DataSet部分功能實(shí)現(xiàn)網(wǎng)站登錄
這篇文章主要介紹了利用DataSet部分功能實(shí)現(xiàn)網(wǎng)站登錄 ,需要的朋友可以參考下2017-05-05SQL WHERE IN參數(shù)化編譯寫法簡(jiǎn)單示例
這篇文章主要給大家介紹了關(guān)于SQL WHERE IN參數(shù)化編譯寫法的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用SQL具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11Navicat11全系列激活教程圖文詳解(Navicat注冊(cè)機(jī))
這篇文章主要介紹了Navicat11全系列激活教程圖文詳解(注冊(cè)機(jī)),本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11你也許連刪庫(kù)跑路都不會(huì)(delete、drop和truncate刪除數(shù)據(jù))
這篇文章主要給大家介紹了關(guān)于delete、drop和truncate刪除數(shù)據(jù)的方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11