Home » Developer & Programmer » JDeveloper, Java & XML » Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError
Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #91301] Thu, 04 July 2002 06:37 Go to next message
Baris Aksu
Messages: 4
Registered: January 2002
Junior Member
Hi,

I tried to connect to an Oracle8i(8.1.7.0.0) database from a servlet using OCI Driver(8.1.7.1 for JDK 1.2). A ServletException was thrown with a root cause of
java.lang.UnsatisfiedLinkError: get_env_handle.
The same program runs without an error using thin driver. I have Oracle8i client installed and i have the ocijdbc8.dll in my PATH environment variable. classes12.zip(renamed as classes12.jar for Tomcat) is in %JAVA_HOME%jrelibext. Database server is up
and running, i have confirmed that ocijdbc8.dll could be loaded by a test program using "System.loadLibrary("ocijdbc8");".

My platform : Windows2000 version5.0(Service Pack 2), Oracle8i Client; Apache2.0.39 Web Server, Tomcat4.0.4 Servlet/JSP Container, J2SDK1.4.0, Oracle8i 8.1.7.1 JDBC/OCI Driver

Here is the code snippet that throws an exception while trying to get a connection:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci8:@my_database","username","password");

I know that this version of OCI driver is for use with JDK1.2, but what i try to do is a simple connect not requiring any JDK1.4 features. So does this may be the source of problem?

As far as i know, Oracle9i 9.2.0.1 JDBC/OCI Driver supports jdk1.4. So, in order to be able to use jdk1.4; I have to install Oracle9i Client for use
with OCI driver, I have to download Oracle9.2.01 JDBC/OCI driver with the necessary dll's, right?

What's more important is that; Will i be able to connect to a Oracle8i(8.1.7) database?

Any suggestion/help will be appreciated....
Re: Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #91304 is a reply to message #91301] Fri, 05 July 2002 05:47 Go to previous messageGo to next message
Baris Aksu
Messages: 4
Registered: January 2002
Junior Member
Hi all,

Here is what i learned from two days trying to access an Oracle8i database using OCI driver.

1)In order to use OCI driver, you should have an Oracle client installed. Suppose you have installed Oracle8i(8.1.7) client from cd, and now you go to otn(otn.oracle.com) and download the suitable JDBC/OCI driver(Oracle8i 8.1.7.1 JDBC/OCI Driver) and after renaming the "classes12.zip" file as "classes12.jar" for Tomcat, you put it into somewhere so that CLASSPATH references it, or directly into %JAVA_HOME%jrelibext.

You are sure that you have the "ocijdbc8.dll" is in your PATH(possibly in %ORAHOME%bin) and you have also confirmed that it could be loaded by a simple test program using "System.loadLibrary("ocijdbc8");".
You have a very simple test servlet that has tese critical lines:
^^^^^^^^^^^^^^^^^^^^^^^^^^
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci8:@database_url","username","password");
^^^^^^^^^^^^^^^^^^^^^^^^^^
where database_url is of the form "jdbc:oracle:oci8:@host:port:SID"

Now you try to access the URL http://localhost/servlet/OracleOCIServlet (or localhost:8080... if you use Tomcat without Apache) and what you get is a

^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ServletException with a root cause of java.lang.UnsatisfiedLinkError:get_env_handle.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You confirm that your simple program works with the "thin" driver, you apply to Oracle metalink to no avail...and you are stuck!!!

First, this 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."(Java Programming with Oracle JDBC, from O'reilly).

Second, give up the driver you have downloded from otn, go to the directory %ORAHOME%jdbclib and use the classes12.zip file there....

This will rescue you from this UnsatisfiedLinkError.

2)You have so far changed the classes12.zip file from otn with the one that came with your client installation, and now you get this error:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ORA-06401 NETCMN: invalid driver designator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

First, Oracle documentation says :
"Cause: The login (connect) string contains an invalid driver designator.
Action: Correct the string and re-submit."

Second, change the database_url(of the form "jdbc:oracle:oci8:@host:port:SID" with this one:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(description=(address=(host=myhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Now, if everything else is pure, you must be accessing Oracle8i.

I hope these hints can help somebody struggling with Tomcat/Oracle couple with OCI...
Re: Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #91745 is a reply to message #91304] Thu, 30 January 2003 12:09 Go to previous messageGo to next message
Andrey
Messages: 21
Registered: January 1999
Junior Member
Hi,

I'm trying to configure Tomcat to use OCI connection with Oracle XSQL.
Do you mean I should replace
<dburl>jdbc:oracle:oci8:@SERVER:PORT:SID</dburl>
with
<dburl>(description=(address=(host=myhost)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))</dburl> ?

Or what would be the solution ?
I'm getting such messages :
XSQL-004: Could not acquire a database connection named: AndreTest
XSQL-007: Cannot acquire a database connection to process page.

Thanks,
Andrey
Re: Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #91762 is a reply to message #91304] Thu, 06 February 2003 23:29 Go to previous messageGo to next message
Amol
Messages: 12
Registered: June 2001
Junior Member
thanks!
Re: Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #91783 is a reply to message #91304] Sat, 15 February 2003 03:50 Go to previous messageGo to next message
krishna
Messages: 141
Registered: October 1998
Senior Member
hi,

GR8 job.
It is really nice to see somebody sharing their learning points with others, so that others won't suffer.
Tnx a lot.

with regards,
krishna.
Re: Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #109458 is a reply to message #91304] Thu, 24 February 2005 12:15 Go to previous messageGo to next message
Amy Haiken
Messages: 1
Registered: February 2005
Junior Member
This was also very helpful for the occi connection:

connection = env->createConnection( userName, userPwd,
"(description=(address=(host=hostname)(protocol=tcp)(port=portnum))(connect_data=(sid=instance_name)))");

This worked, but the connectionString format that was recommended "host:port/database" didn't work and gave me the Oracle error ORA-06401.

Thanks for your help,
Amy
Re: Connection to 8.1.7 Database Fails With OCI8 Driver : UnsatisfiedLinkError [message #119566 is a reply to message #91304] Fri, 13 May 2005 07:16 Go to previous message
KannanKarthikeyan
Messages: 1
Registered: May 2005
Location: Singapore
Junior Member
HI,

How to connect to default user name.our user ids are os authenticated. and we are getting the following error.

java.sql.SQLException: ORA-01004: default username feature not supported; logon denied

is there any way to connect..? Thanks

Have specified the below ways inside my java code to connect.

Option 1:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci8:@dbname","","");

Option 2:
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:oci8:/@cqdevl");

However when substituted with actual user id and password the connection works
conn = DriverManager.getConnection("jdbc:oracle:oci8:@dbname", user , password);

echo $TNS_ADMIN
/data/oracle/product/8.1.7.4/network/admin
Previous Topic: POOL - Maximun Open Cursors Exceeded
Next Topic: How to create an XSL-FO template for XML Publisher 5.0
Goto Forum:
  


Current Time: Tue Feb 27 04:16:18 CST 2024