自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle 數(shù)據(jù)庫中三種不同類型的JDBC驅(qū)動

數(shù)據(jù)庫 Oracle
我們今天主要介紹的是Oracle 數(shù)據(jù)庫里三種不同類型的JDBC驅(qū)動以及其實際相關(guān)代碼的描述,以下就是文章的具體內(nèi)容的描述。

以下的文章主要介紹的是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和服務(wù)器配置。

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。因為是在服務(wù)器內(nèi)部使用,他使用默認或當前的會話連接來訪數(shù)據(jù)庫,不需要用戶名密碼等,也不需要數(shù)據(jù)庫url。

在應(yīng)用開發(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ù)庫服務(wù)器,使用到了客戶端的net manager里的數(shù)據(jù)庫服務(wù)配置。

因為oci方式最終與數(shù)據(jù)庫服務(wù)器通信交互是用的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之后提供了精簡客戶端,安裝的過程應(yīng)該包括上面的那些工作。

 

  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ū)動的介紹,望你能有所收獲。

【編輯推薦】

  1. OracleSQL調(diào)優(yōu)的作用是什么?
  2. Oracle權(quán)限分類及其具體內(nèi)容
  3. Oracle 查詢記錄相關(guān)效率的查詢
  4. Oracle存取LONG類型字段的方案描述
  5. Oracle數(shù)據(jù)庫的類型LONG功能的介紹
責任編輯:佚名 來源: 博客園
相關(guān)推薦

2010-04-12 16:35:15

Oracle數(shù)據(jù)庫

2010-04-02 13:15:01

Oracle跟蹤

2009-07-22 11:33:14

JDBC連接Sybas

2010-07-07 09:14:35

SQL Server數(shù)

2011-05-26 13:16:37

Oracle數(shù)據(jù)庫備份

2010-11-19 14:51:09

Oracle數(shù)據(jù)庫關(guān)閉

2010-10-26 13:33:08

Oracle自動備份

2022-12-20 10:48:24

數(shù)字化轉(zhuǎn)型首席信息官

2019-11-23 17:10:58

MySQL數(shù)據(jù)庫default

2009-08-06 15:26:18

C#異常類型

2010-03-30 11:15:26

Oracle數(shù)據(jù)庫

2011-08-01 18:42:40

分區(qū)維度物化視圖

2010-05-10 09:48:46

Oracle優(yōu)化器

2011-04-12 11:46:26

Oracle優(yōu)化器

2017-06-29 14:12:13

SQL ServerMysqlOracle

2018-01-17 15:02:28

VMware網(wǎng)絡(luò)連接

2011-05-20 17:08:32

2010-07-29 09:56:45

Flex數(shù)據(jù)庫

2020-08-27 07:00:00

游戲游戲測試測試技術(shù)

2024-02-26 13:47:00

C#Socket數(shù)據(jù)接收
點贊
收藏

51CTO技術(shù)棧公眾號