When a Java program connects to the oracle database, the oci driver has better performance than the thin driver. The main difference is that the oracle client does not need to be installed when the thin driver is used, but the oracle client must be installed when oci is used.
Switching from the thin driver to the oci driver is easy to configure. You only need to replace the connection string java: oracle: thin: @ hostip: 1521: Instance name with java: oracle: oci @ local service name. For example:
Slave
Jdbc: oracle: thin: @ 10.1.1.2: 1521: shdb
Changed:
Jdbc: oracle: oci8: @ shdb
However, this machine must install the oracle database client and configure the local service name. At the same time, you must specify the NLS_LANG environment variable, the NLS_LANG environment variable is used to control the character set and localization habits used by the client to display data in the oracle database. Generally, the NLS_LANG character set is specified as the character set used by the database, so there will be no garbled java display.
There are two options for installing the oracle database client. One is to use the oracle database installation CD to install the corresponding version of the oracle client. The second is to download the real-time client extracted from oracle. The real-time client does not need to be installed. Unzip the downloaded package.
To enable java web to normally access oracle through the oci driver, you also need to configure relevant variables correctly on the client. The main features are as follows:
For windows and oracle clients:
1. Add % ORACLE_HOME % \ lib to the path environment variable.
2. Add % ORACLE_HOME % \ jdbc \ lib \ classes12.jar to the classpath environment variable, or copy classes12.jar to the tomcat comman \ lib directory.
For windows and oracle Real-Time clients (assuming that the real-time client is decompressed on the d disk ):
1. Add d: \ instantclient_10_2 to the path environment variable;
2. Add d: \ instantclient_10_2 \ classes12.jar to the classpath environment variable, or copy classes12.jar to the tomcat comman \ lib directory.
For linux systems and oracle clients:
1. Add the following to the. bash_profile file in the user's home directory that uses tomcat:
Exprot ORACLE_HOME =/u01/app/oracle/product/9.2.0.4
Export LD_LIBRARY_PATH = $ ORACLE_HOME/lib
2. Copy classes12.jar to the tomcat comman \ lib directory.
For linux systems and oracle Real-Time clients:
1. Add the following to the. bash_profile file in the user's home directory that uses tomcat:
Exprot ORACLE_HOME =/instantclient_10_2
Export LD_LIBRARY_PATH = $ ORACLE_HOME/lib
2. Copy classes12.jar under the instantclient_10_2 directory to the comman \ lib directory of tomcat.
If a tomcat contains several applications that need to be connected to the oracle database, note that, do not place the oracle classes12.jar/zip file under the WEB-INF/lib directory for each application. Instead, put the classes12.jar/zip file in the common/lib directory of tomcat. Otherwise, the ojdbclib9/10 library will be reloaded.
When using the oracle Real-time client, you can create a tnsnames. ora connection string under the instantclient_10_2 directory, for example:
SHDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS =
(PROTOCOL = TCP) (HOST = 10.1.1.236) (PORT = 1521 )))
(CONNECT_DATA = (SERVICE_NAME = shdb )))
Author: "Flying Freely"