Oracle 8i with OCI client

Introduction

Whilst not strictly addressing the creation of a JNDI DataSource using the OCI client, these notes can be combined with the Oracle and DBCP solution above.

In order to use OCI driver, you should have an Oracle client installed. You should have installed Oracle8i(8.1.7) client from cd, and download the suitable JDBC/OCI driver(Oracle8i 8.1.7.1 JDBC/OCI Driver) from otn.oracle.com.

After renaming classes12.zip file to classes12.jar for Tomcat, copy it into $CATALINA_HOME/lib. You may also have to remove the javax.sql.* classes from this file depending upon the version of Tomcat and JDK you are using.

Putting it all together

Ensure that you have the ocijdbc8.dll or .so in your $PATH or LD_LIBRARY_PATH (possibly in $ORAHOME\bin) and also confirm that the native library can be loaded by a simple test program usingSystem.loadLibrary(“ocijdbc8”);

You should next create a simple test servlet or jsp that has these critical lines:

DriverManager.registerDriver(new

oracle.jdbc.driver.OracleDriver());

conn =

DriverManager.getConnection(“jdbc:oracle:oci8:@database”,”username”,”password”);

where database is of the form host:port:SID Now if you try to access the URL of your test servlet/jsp and what you get is a ServletException with a root cause of java.lang.UnsatisfiedLinkError:get_env_handle.

First, the UnsatisfiedLinkError indicates that you have

  • a mismatch between your JDBC classes file and your Oracle client version. The giveaway here is the message stating that a needed library file cannot be found. For example, you may be using a classes12.zip file from Oracle Version 8.1.6 with a Version 8.1.5 Oracle client. The classeXXXs.zip file and Oracle client software versions must match.
  • A $PATH, LD_LIBRARY_PATH problem.
  • It has been reported that ignoring the driver you have downloaded from otn and using the classes12.zip file from the directory $ORAHOME\jdbc\lib will also work.

Next you may experience the error ORA-06401 NETCMN: invalid driver designator

The Oracle documentation says : “Cause: The login (connect) string contains an invalid driver designator. Action: Correct the string and re-submit.” Change the database connect string (of the form host:port:SID) with this one: (description=(address=(host=myhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))

Ed. Hmm, I don’t think this is really needed if you sort out your TNSNames – but I’m not an Oracle DBA 🙂

Non-DBCP Solutions
Common Problems

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello 👋
Can we help you?