日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Oracle數(shù)據(jù)庫中三種不同類型的JDBC驅(qū)動

以下的文章主要介紹的是Oracle 數(shù)據(jù)庫里三種不同類型的JDBC驅(qū)動,我們大家都知道Oracle 中的jdbc驅(qū)動主要有以下的三類,即,1、JDBC OCI: oci是Oracle call interface的縮寫,此驅(qū)動類似于傳統(tǒng)的ODBC 驅(qū)動。

因為它需要Oracle Call Interface and Net8,所以它需要在運行使用此驅(qū)動的JAVA程序的機器上安裝客戶端軟件,其實主要是用到orcale客戶端里以dll方式提供的oci和服務器配置。

2、JDBC Thin: thin是for thin client的意思,這種驅(qū)動一般用在運行在WEB瀏覽器中的JAVA程序。它不是通過OCI or Net8,而是通過Java sockets進行通信,是純java實現(xiàn)的驅(qū)動,因此不需要在使用JDBC Thin的客戶端機器上安裝orcale客戶端軟件,所以有很好的移植性,通常用在web開發(fā)中。

3、JDBC KPRB: 這種驅(qū)動由直接存儲在數(shù)據(jù)庫中的JAVA程序使用,如Java Stored Procedures 、triggers、Database JSP's。因為是在服務器內(nèi)部使用,他使用默認或當前的會話連接來訪數(shù)據(jù)庫,不需要用戶名密碼等,也不需要數(shù)據(jù)庫url。

在應用開發(fā)的時候,通常是用前面兩種方式,下面是數(shù)據(jù)庫url的寫法:

 
 
 
  1. jdbc:Oracle :thin:@server ip: service  
  2. jdbc:Oracle :oci:@service  

 

看來oci的還更加簡潔,ip可以省掉不寫了,這是因為oci驅(qū)動通過客戶端的native java methods來條用c library方式來訪問數(shù)據(jù)庫服務器,使用到了客戶端的net manager里的數(shù)據(jù)庫服務配置。

因為oci方式最終與數(shù)據(jù)庫服務器通信交互是用的c library庫,理論上性能優(yōu)于thin方式,據(jù)說主要是體現(xiàn)在blob字段的存取上。

開發(fā)Oracle 數(shù)據(jù)庫經(jīng)常用到的 pl sql dev使用的估計是oci方式,需要安裝客戶端,但也可以不安裝,但是要抽出其中的oci相關(guān)的dll即jar包、注冊環(huán)境變量、配置偵聽文件等。Oracle 在10g之后提供了精簡客戶端,安裝的過程應該包括上面的那些工作。

 
 
 
  1. How does one connect with the JDBC OCI Driver?  
  2. One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers.  
  3. Code: [Copy to clipboard]  
  4. import java.sql.*;  
  5. class dbAccess {  
  6. public static void main (String args []) throws SQLException  
  7. {  
  8. try {  
  9. Class.forName ("Oracle .jdbc.driver.Oracle Driver");  
  10. } catch (ClassNotFoundException e) {  
  11. e.printStackTrace();  
  12. }  
  13. Connection conn = DriverManager.getConnection  
  14. ("jdbc:Oracle :oci8:@ORA1", "scott", "tiger");  
  15. // or oci9 @Service, userid, password  
  16. Statement stmt = conn.createStatement();  
  17. ResultSet rset = stmt.executeQuery (  
  18. "select BANNER from SYS.V_$VERSION"  
  19. );  
  20. while (rset.next())  
  21. System.out.println (rset.getString(1)); // Print col 1  
  22. stmt.close();  
  23. }  
  24. }  
  25. How does one connect with the JDBC KPRB Driver?  
  26. One can obtain a handle to the default or current connection 
    (KPRB driver) by calling the Oracle Driver.defaultConenction() method. 
    Please note that you do not need to specify a database URL, 
    username or password as you are already connected to a database session. 
    Remember not to close the default connection. 
    Closing the default connection might throw an exception in future releases of Oracle .  
  27. import java.sql.*;  
  28. Code: [Copy to clipboard]  
  29. class dbAccess {  
  30. public static void main (String args []) throws SQLException  
  31. {  
  32. Connection conn = (new  
  33. Oracle .jdbc.driver.Oracle Driver()).defaultConnection();  
  34. Statement stmt = conn.createStatement();  
  35. ResultSet rset = stmt.executeQuery (  
  36. "select BANNER from SYS.V_$VERSION"  
  37. );  
  38. while (rset.next())  
  39. System.out.println (rset.getString(1)); // Print col 1  
  40. stmt.close();  
  41. }  
  42. }   

以上的相關(guān)內(nèi)容就是對Oracle 數(shù)據(jù)庫中三種類型的JDBC驅(qū)動的介紹,望你能有所收獲。


新聞標題:Oracle數(shù)據(jù)庫中三種不同類型的JDBC驅(qū)動
文章出自:http://www.dlmjj.cn/article/dhddehg.html