




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、j2ee應(yīng)用中與oracle數(shù)據(jù)庫(kù)的連接connection to the oracle database in j2ee applicationsin j2ee application development, the creation of applications and database connections is one of the problems we often encounter. here i mainly talk about in the local application way by oci, thin and jdbcodbc bridge connectin
2、g oracle database, the iplanet application server 6. 5 and sun java system application server 7 configuration and application of the oracle database connection pool to obtain a connection from the connection poolthe oracle database connection is obtained locally through jdbcthere are three ways to g
3、et an oracle database connection through jdbc: oci, thin, and jdbcodbc bridge the oci approach relies on the local dynamic link library, which can be used if the oracle database die nt is installed locall y. the thin method is a database connection for pure java; the jdbcodbc bridge approach relies
4、on the configuration of the local odbc database source, which is generally not adopted.1, oci waythe oracle client is installed locally, and after the installation, you can find it in the installstion path / jdbc/lib/classes12.zip file, we set the path of classesl2.zip in the environment variable cl
5、asspaththe oracle database connection is obtained locally through the oci method through the following database connection class* get the database connection locally* /package com j2ee.import javaimport javaimport javax sql.import javaimport oracleimport javax/ * * get the oracle database connection
6、 through oci* /public class dbconnectionfindl static string sdbdriver = "oracle, driver.final static string sconnstr 二 jdbc: oracle: oci8: sr/sr oral99/,/ * * /public dbconnection ()/ * * get the oracle database connection* /public java.sql. connection connectdbbyoci ()java. sql. connection cor
7、m 二 null;the tryclass forname (sdbdriver);conn 二 drivermanager getconnection (sconnstr);catch (exception e)( error:")return the conn.in the connection string "jdbc: oracle: oci8: sr/sr oral99,z, the sr/sr" user name and password for oracle users, ,oral99,/ for the database service nam
8、e2, thin wayfirst to the oracle technology network(http:/otn.oracle com/global/cn/software/tech/java/sqlj_jd be/indexhtml) to download the oracle jdbc drivers, likewise after downloading the zip file path set in the classpath environment variablethe oracle database connection is then obtained locall
9、y through the thin method locally via the following database connection class./ * * get the database connection locally* /package com j2eeimport javaimport javaimport javax sql.import javaimport oracleimport javax/ * * * get the oracle database connection through thinpublic class dbconnectionprivate
10、 string sconnstr 二"“;/ * * default constructor* /public dbconnection ()sconnstr 二 jdbc: oracle: thin: 10.1. 4.199: oral99;/ * * param ip, servicename* /public dbconnection (string ip, string servicename)sconnstr 二 jdbc: oracle: thin:+ ip + : 1521: +servicename;* get the connection to the oracle
11、 database through thin.* /public java. sql. connection connectdbbythin ()java. sql. connection conn = null;the tryclass forname (sdbdriver);conn 二 drivermanager, getconnection (sconnstr,/z sr "、sr);catch (exception e)( error: /z)return the conn./ * * get the connection to the oracle database th
12、rough thin.* param userid, password* /public java sql. connection connectbyjdbc (string userid,string password)javasql. connection conn = null;the tryclass forname (sdbdriver);drivermanager getco rm ection (sconnstr, userid, password);catch (exception e)( error:')return the connthis approach is
13、flexible, simple, with a strong portability and applicability as long as you are aware of the connection string "jdbc: oracle: thin: 10. 1. 4. 199:1521: oral99,z, the specific parameters are set3, jdbcodbc bridge modefirst through management tools in the data source to add local oracle database
14、 connection, and then through the following database connection class, locally by jdbcodbc bridge for oracle database connection.* get the database corm ection locally * /package com j2eeimport javaimport java.import javax sql.import javaimport oracleimport javax/ * * get the oracle database corm ec
15、tion through the jdbcodbcbridge* /public class dbconnection* /public dbconnection ()/ * * get the oracle database connection* /public javasql. connection connectdbcbridge ()java. sql. connection conn 二 null;the tryforname (“ sun. jdbcdbcdriver “);con 二 drivermanagergetconnection (“ jdbc: ora199 “, s
16、r );catch (exception e)( error:")return the conn.the first parameter in the getconnection method jdbc: odbc: oral99,/ in the ,oral99,/ for local odbc data source and data source name, the second and third parameters respectively as the oracle user name and passwordthe oracle database connection
17、 is obtained through the connection poolthis part focuses on the iplanet application server 6. 5 and sun java system application server 7 oracle database connection pool configuration, and how to use the connection pool in the application of the database connection.the iplanet application server 6.5
18、 connection pool configurationopens first iplanet 6.5 application server admin console, select "database" panel, and then select "external jdbc drivers" option, click "add"button, in the pop-up dialog box, add a jdbc driver called "ora - type4"driver classpath
19、: this parameter fills the physical path of the classesl2. zip file.then select add"in the ''external jdbc datasources,z and adda jndi name box.to the z,credit2,z data source in the pop-up dialogdrivertype:select "ora type4;datasource:oral99, for oracle database service name;dataso
20、urce:oral99, for oracle database service name;connection pool parameters: the default settings are shown in the diagram, which can be changed depending on your environmentafter save the settings, the ''datasource selection box,choose just added credit2 data source, and select "vendor sp
21、ecific properties" button. add a url attribute to the conversation.at this point, the database connection pool in the iplanet application server 6.5 has been configured and the service is reconfigured to take effectthe sun java system application server 7 connection pool configurationplace the
22、classesl2.zip file before configuring / server1 / lib directory. through the browser open port 4848 sun java system application server management interface, select "serverl" 一 > jdbc 一 > "'connection pools" under the "newadd an oracle database connection pool calle
23、d "myconnectionpoo1"next" nextfill in the ''datasource classname,z in ''generaldelete the attributes that you don,t need in "properties" and add "url" properties/,datasourcename,/ fills in the oracle database service namethe following connection poo
24、t s default settings can be adjusted according to the circumstances of your environmentselect "finish" to complete the connection pool settingsthe next step is to create a jndi for the ,zmyconnectionpoo 1 connection pool so that the application can get the connection in the connection pool
25、 through the name"serverl" - > "jdbc" -> "jdbc resources" under "new."at this point, the database connection pool in the sun java system application server7 has been configured and the service has been reconfigured to take effectget the connection throug
26、h the connection poolabove in iplanet application server 6.5 and sun java system application server7 configured in the connection pool can be covered by the following database connection class, oracle database connection from the connection pool./ * * get the database connection from the connection pool* /package com j2eeimport javaimport javaimport javax sql.import the java 10.*;import oracleimport javax* get the oracle database connection by connection poolingpublic class dbconnection* /public dbconnection ()* get the oracle database connection* /public java. sql. connect!on connectdbbyc
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- Unit 3 ATravel Plan Lesson 13 Beijing Is Great!(教學(xué)設(shè)計(jì)) -2024-2025學(xué)年冀教版(三起)英語(yǔ)五年級(jí)上冊(cè)
- 2023九年級(jí)化學(xué)下冊(cè) 第十單元 酸和堿 課題2 酸和堿的中和反應(yīng)第2課時(shí) 溶液的pH及其應(yīng)用教學(xué)設(shè)計(jì) (新版)新人教版
- Unit 7 Lesson 38 Hobbies Are Fun!2024-2025學(xué)年八年級(jí)英語(yǔ)上冊(cè)同步教學(xué)設(shè)計(jì)(冀教版)河北專(zhuān)版
- 船舶衛(wèi)生與衛(wèi)生設(shè)施管理
- 3 荷花 教學(xué)設(shè)計(jì)-2024-2025學(xué)年語(yǔ)文三年級(jí)下冊(cè)統(tǒng)編版
- 4《地球 我們的家園》《環(huán)境問(wèn)題敲響了警鐘》教學(xué)設(shè)計(jì)-2023-2024學(xué)年道德與法治六年級(jí)下冊(cè)統(tǒng)編版
- 七年級(jí)生物上冊(cè) 第一單元 第一節(jié) 生物的基本特征教學(xué)設(shè)計(jì) 新人教版
- Unit 6 The power of plants 第6課時(shí)Presenting ideas +Reflection教學(xué)設(shè)計(jì) -2024-2025學(xué)年外研版英語(yǔ)(2024)七年級(jí)上冊(cè)
- 2033三年級(jí)數(shù)學(xué)下冊(cè) 五 年、月、日第4課時(shí) 24 時(shí)計(jì)時(shí)法教學(xué)設(shè)計(jì) 蘇教版
- Module 2 Unit 2 What are you doing?(教學(xué)設(shè)計(jì))-2024-2025學(xué)年外研版(三起)英語(yǔ)四年級(jí)上冊(cè)
- 2025年全民國(guó)家安全教育日知識(shí)競(jìng)賽考試題庫(kù)500題(含答案)
- 跨境電商網(wǎng)站的設(shè)計(jì)挑戰(zhàn)試題及答案
- 2024中國(guó)山東省集中供熱行業(yè)發(fā)展趨勢(shì)預(yù)測(cè)及投資戰(zhàn)略咨詢報(bào)告
- 肯德基店面試試題及答案
- 2023國(guó)家衛(wèi)健委中國(guó)結(jié)直腸癌診療規(guī)范
- 深信服下一代防火墻技術(shù)白皮書(shū)20231120
- 廣州市白云區(qū)2025年招考社區(qū)居委會(huì)專(zhuān)職人員高頻重點(diǎn)模擬試卷提升(共500題附帶答案詳解)
- 2025年遼寧省大連市高考語(yǔ)文一模試卷
- 統(tǒng)編版語(yǔ)文七年級(jí)下第18課《井岡翠竹》公開(kāi)課一等獎(jiǎng)創(chuàng)新教學(xué)設(shè)計(jì)
- 蘇教版六年級(jí)數(shù)學(xué)下冊(cè)第三單元《解決問(wèn)題的策略(1)》課件
- 七年級(jí)數(shù)學(xué)新北師大版(2024)下冊(cè)第一章《整式的乘除》單元檢測(cè)習(xí)題(含簡(jiǎn)單答案)
評(píng)論
0/150
提交評(píng)論