成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

Oracle數(shù)據(jù)庫(kù)的密集型實(shí)際應(yīng)用程序的開發(fā)

數(shù)據(jù)庫(kù) Oracle
以下的文章主要是介紹 UCP JDBC 連接池用到的HR/HR Oracle 數(shù)據(jù)庫(kù)的示例模式建立連接的實(shí)際操作方案的描述。以下就是正文的介紹。

我們都知道再開發(fā)Oracle數(shù)據(jù)庫(kù)的密集型實(shí)際應(yīng)用程序時(shí),使用相關(guān)連接池而受益。之所以是因?yàn)檫@樣,我們才能夠重用連接,而不是在每次請(qǐng)求連接時(shí)都重新創(chuàng)建一個(gè)新連接。連接池節(jié)約了創(chuàng)建新數(shù)據(jù)庫(kù)連接所需的資源,并提高了應(yīng)用程序的性能,因?yàn)閯?chuàng)建新連接始終是一個(gè)性能密集型操作。

 

Oracle Universal Connection Pool for JDBC 表示一個(gè)用于緩存 JDBC 連接的全功能實(shí)現(xiàn)。UCP 是一個(gè)非常有用的特性,它將使您可以重用連接對(duì)象,從而可以提高獲取連接過程的速度并節(jié)約打開新數(shù)據(jù)庫(kù)連接所需的資源。

假設(shè)您希望創(chuàng)建一個(gè) UCP JDBC 連接池來重用到 HR/HR Oracle 數(shù)據(jù)庫(kù)示例模式的已建立連接。以下程序是一個(gè) UCP JDBC 連接池實(shí)際運(yùn)行的簡(jiǎn)單示例,將向您展示如何完成此操作。您將首先創(chuàng)建一個(gè)支持池的數(shù)據(jù)源實(shí)例,然后設(shè)置連接和池的屬性。完成后,您將從池中借用一個(gè)連接,然后使用該連接與數(shù)據(jù)庫(kù)交互。***,您將關(guān)閉該連接,將其返回到池。

 

  1. import java.sql.*; import oracle.ucp.jdbc.PoolDataSourceFactory; 
    import oracle.ucp.jdbc.PoolDataSource; public class UcpConnection 
    { public static void main(String args[]) throws SQLException 
    { try { //Creating a pool-enabled data source PoolDataSource 
    pds 
    PoolDataSourceFactory.getPoolDataSource(); 
    //Setting connection properties of the data source pds.
    setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); 
    pds.setURL("jdbc:oracle:thin:@//localhost:1521/XE"); pds.setUser("hr"); 
    pds.setPassword("hr"); //Setting pool properties pds.setInitialPoolSize(5); 
    pds.setMinPoolSize(5); pds.setMaxPoolSize(10); 
    //Borrowing a connection fro th oo Connection 
    con = pds.getConnection();  
  2. ount(); System.out.println("\nAvailable connections: 
    " + avlConnCount); int 
    brwConnCount = pds.getBorrowedConnectionsCount(); 
    System.out.println("\nBorrowed connections: " + brwConnCount); 
    //Working with the connection Statement 
    stmt = conn.createStatement(); 
    ResultSet 
    rs = stmt.executeQuery("select user from dual"); 
    while(rs.next()) System.out.println("\nConnected as: "+rs.getString(1)); 
    rs.close(); //Returning the connection to the pool conn.close(); 
    conn=null
    System.out.println("\nConnection returned to the pool"); 
    //Checking the number of available and borrowed connections again 
    avlConnCount = 
    pds.getAvailableConnectionsCount(); 
    System.out.println("\nAvailable connections: " + avlConnCount); 
    brwConnCount = pds.getBorrowedConnectionsCount(); 
    System.out.println("\nBorrowed connections: " + brwConnCount); } 
    catch(SQLException e) 
    { System.out.println("\nAn SQL exception occurred : " + e.getMessage()); } } } 

 

 

這里值得注意的是關(guān)閉連接時(shí)的變化。以上程序的輸出闡釋了關(guān)閉從 UCP JDBC 連接池中借用的連接將使該連接返回到池,以供下一次連接請(qǐng)求使用。

 

該應(yīng)用程序的輸出應(yīng)如下所示:

 

  1. Connection borrowed from the poolAvailable connections: 
    4Borrowed connections: 1Connected as: HRConnection returned 
    to the poolAvailable connections: 5Borrowed connections: 0 

 上述的相關(guān)內(nèi)容就是使用 UCP 緩存 JDBC 連接對(duì)開發(fā)Oracle數(shù)據(jù)庫(kù)密集型應(yīng)用程序的描述,希望會(huì)給你帶來一些幫助在此方面。

 

【編輯推薦】

  1. Oracle數(shù)據(jù)庫(kù)的異構(gòu)服務(wù)原理描述
  2. Oracle細(xì)粒度如何進(jìn)行訪問
  3. 用Oracle屏蔽英文來提示信息的正確方法
  4. Oracle進(jìn)程中出現(xiàn)帶鎖狀況的解決
  5. Oracle動(dòng)態(tài)Web開發(fā)實(shí)例演示
責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2018-03-22 09:16:06

密集型場(chǎng)景SSD

2022-06-27 14:01:31

LZ4 分析數(shù)據(jù)密集型壓縮算法

2011-11-14 13:29:22

移動(dòng)應(yīng)用開發(fā)移動(dòng)開發(fā)移動(dòng)互聯(lián)網(wǎng)

2025-02-24 09:00:00

CPUI/O密集型任務(wù)

2012-12-14 11:00:02

VDI桌面虛擬化

2012-10-08 09:45:22

數(shù)據(jù)密集型處理系統(tǒng)

2010-04-13 12:23:34

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

2010-04-15 09:36:42

2010-04-21 11:27:55

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

2010-04-22 12:26:10

Oracle數(shù)據(jù)

2010-04-19 11:37:20

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

2020-09-07 07:33:01

NodejsCPU密集型

2010-05-13 13:49:09

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

2010-04-19 09:26:04

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

2010-07-14 13:14:01

SQL Server數(shù)

2021-02-23 23:06:31

數(shù)據(jù)庫(kù)Redis技術(shù)

2022-05-10 08:00:00

數(shù)據(jù)庫(kù)數(shù)據(jù)庫(kù)監(jiān)控監(jiān)控系統(tǒng)

2011-03-30 11:15:35

SQL Server數(shù)應(yīng)用程序

2011-11-11 09:11:09

云計(jì)算HPC集群

2010-03-30 11:15:26

Oracle數(shù)據(jù)庫(kù)
點(diǎn)贊
收藏

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

主站蜘蛛池模板: 少妇诱惑av| 激情五月激情综合网 | 69福利影院 | 欧美一级黄色免费看 | 亚洲欧美激情精品一区二区 | 国产欧美一区二区在线观看 | av片在线播放 | 欧美一级二级三级视频 | 国产欧美精品区一区二区三区 | 国精产品一区二区三区 | 国产成人一区二区三区电影 | 在线精品一区二区三区 | 欧美日韩一区在线观看 | 国产成人精品免费 | 欧美日韩在线一区二区 | av看片网站| 国产精品资源在线 | 欧美精品在线免费 | 亚洲精品久久久一区二区三区 | 999热精品| 天天干狠狠操 | 成人午夜在线 | 九九免费 | 日韩中文字幕 | 日韩激情在线 | 日韩电影免费在线观看中文字幕 | 久久久91精品国产一区二区三区 | 久久精品一二三影院 | 欧美不卡 | 99热国产免费 | 亚洲精品2区 | 国产精品久久久久av | 亚洲一区二区电影在线观看 | 欧美a区| 国产精品久久久久久久久久久免费看 | www.欧美| 男女羞羞免费视频 | 不卡一区二区三区四区 | 欧美精品一区二区三区四区五区 | 欧美片网站免费 | 久草中文网 |