首先Java下根據JDBC規範串連資料庫,有幾種形式,參考
http://djdnmq.iteye.com/blog/356468 oracle 驅動oci thin 區別
Oracle用戶端準備
10201_client_linux32.zip
安裝完成後,需要確保在終端中可以正確的執行sqlplus命令
Oracle環境變數
如果Tomcat是服務,需要把Oracle的安裝環境變數寫到TOMCAT中,類似如下
Tomcat加入/home/**/apache-tomcat-6.0.35/bin/catalina.sh開頭,當前的使用者加入:.bash_profile的末尾,具體的內容如下:
export ORACLE_HOME=/home/
** /oracle/product/10.2.0/client_1
export ORACLE_BASE=/home/
** /oracle/product/10.2.0
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME:$ORACLE_HOME/lib:$ORACLE_HOME/jdbc/lib:${LD_LIBRARY_PATH}
建立到目標資料庫的TNS串連
類似在/home/**/oracle/product/10.2.0/client_1/bin執行./netmgr
建立到目標資料庫的TNS名字,此時就可以使用JDBC的OCI形式訪問Oracle資料庫了
Web容器訪問Oracle出現如下錯誤的一些參考資料
no ocijdbc10 in java.library.path
https://forums.oracle.com/forums/thread.jspa?threadID=290097
https://forums.oracle.com/forums/thread.jspa?threadID=615281
- JDBC Thin Driver
100% Java client-side JDBC driver for use in client applications, middle-tier servers and applets.
- JDBC OCI Driver
Client-side JDBC driver for use on a machine where OCI is installed.
- JDBC Thin Server-side Driver
JDBC driver for use in Java program in the database to access remote Oracle databases.
- JDBC Server-side Internal Driver Server-side JDBC driver for use by Java Stored procedures. This driver used to be called the "JDBC Kprb Driver".
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc101040-094982.html
https://forums.oracle.com/forums/thread.jspa?threadID=290097