• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JDBC-Oracle connectivity issue with OCI8 drive using oracle 11g client

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JDBC-ORACLE CONNECTIVITY ISSUE WITYH OCI8 DRIVER using oracle 11g client..
I am getting below error when i m trying to access oracle db using oracle 11g client. It works with earlier oracle client versions. how do i resolve this. is there any issue with version of ojdbc6.jar that i am using??? I cant use thin driver since its an old application for which i dont have source files.

Apr 6, 2013 1:00:59 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.UnsatisfiedLinkError: no ocijdbc9 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:262)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:346)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at PettyCash.SysDate.getSysSubSys(SysDate.java:232)
at org.apache.jsp.PettyCash.index_jsp._jspService(org.apache.jsp.PettyCash.index_jsp:186)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Code is as follow for reference

import oracle.jdbc.driver.*;

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection ("jdbc:oracle:oci8:@" + database,db_user, db_pass);


eNVIRONMENT VARIABLES set are as follows:
classpath
C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\classes12.jar;C:\Program Files\apache-tomcat-5.5.12\webapps\ROOT\WEB-INF\lib\ojdbc6.jar;

JAVA_HOME
C:\Program Files\Java\jdk1.5.0_04

PATH
C:\Program Files\Java\jdk1.5.0_04\bin

ORACLE_HOME
D:\Oracle11\product\11.2.0\client_1\BIN
 
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just out of curiosity, any particular reason you have two JDBC drivers in your classpath? classes12.jar and ojdbc6.jar. I might be concerned about Java loading the wrong version of one of the classes and complaining.
 
steve markin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tina Smith wrote:Just out of curiosity, any particular reason you have two JDBC drivers in your classpath? classes12.jar and ojdbc6.jar. I might be concerned about Java loading the wrong version of one of the classes and complaining.




which driver should i use? .i cant change the code since i some source files are missing .below is the Code is as follow for reference.
import oracle.jdbc.driver.*;
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection ("jdbcracleci8:@" + database,db_user, db_pass);
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasn't suggesting changing your code, I was suggesting changing the path that the JVM looks at to load the actual JDBC libraries. You have two possible locations to load the libraries from: classes12.jar and ojdbc6.jar. Both of these contain most of the same classes, although implementation may differ between the classes, and you don't know which DriverManager (the one in classes12 or the one in ojdbc6) the JVM is actually using. I would remove one from your classpath and see if it makes a difference.
 
steve markin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tina Smith wrote:I wasn't suggesting changing your code, I was suggesting changing the path that the JVM looks at to load the actual JDBC libraries. You have two possible locations to load the libraries from: classes12.jar and ojdbc6.jar. Both of these contain most of the same classes, although implementation may differ between the classes, and you don't know which DriverManager (the one in classes12 or the one in ojdbc6) the JVM is actually using. I would remove one from your classpath and see if it makes a difference.



ok. will set class path to any 1 jar file and try..thanks.. just wanted 2 ask does oci driver work with oracle 11g client ??
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used the OCI driver to connect to an Oracle 11g database before. At work we normally use the thin driver, but oci works practically seamlessly in place (just needed to configure the appropriate listener).

I confess I don't really understand why you can't use the thin driver...that's between your application and the database, and the only place it should affect your "code" is the connection string, which you clearly have access to.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are very few features that are available in the OCI driver and not in the thin driver (see the documentation).

Unless you're using some of these, Steve, I'd suggest using the JDBC thin driver. Our Oracle FAQ contains links to some information about driver/database compatibility, documentation and driver download pages.
 
steve markin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now getting a different error
Apr 8, 2013 10:58:10 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1650)


ENVIROMENT VARIABLES SET
USER VARIABLES
CLASSPATH
classpath%;C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;D:\Oracle11\product\11.2.0\client_1\jdbc\lib\ojdbc6.jar;

PATH
C:\Program Files\Java\jdk1.5.0_04\bin

SYSTEM VARIABLES
JAVA_HOME
C:\Program Files\Java\jdk1.5.0_04
PATH
D:\Oracle11\product\11.2.0\client_1\BIN
ORACLE HOME
D:\Oracle11\product\11.2.0\client_1\BIN

what am i doing wrong???..
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually get that if I compile using a higher version of Java than I run with. (eg compile under Java 7 JDK, run under Java 6 JRE). Type "java -version" at a command prompt and see what you get. It's going to need to be at least 1.5.x to work with the Java 5 JDK.

The Oracle install does include a version of Java that is quite low (I think 1.4).
 
steve markin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tina Smith wrote:I usually get that if I compile using a higher version of Java than I run with. (eg compile under Java 7 JDK, run under Java 6 JRE). Type "java -version" at a command prompt and see what you get. It's going to need to be at least 1.5.x to work with the Java 5 JDK.

The Oracle install does include a version of Java that is quite low (I think 1.4).



but i havent specified that in environment variables. also adding ojdbc5.jar still doesnt seem 2 work.can you please check whether below envt variables set are correct or not???
ENVIROMENT VARIABLES SET
USER VARIABLES
CLASSPATH
classpath%;C:\Program Files\apache-tomcat-5.5.12\common\lib\servlet-api.jar;D:\Oracle11\product\11.2.0\client_1\jdbc\lib\ojdbc6.jar;

PATH
C:\Program Files\Java\jdk1.5.0_04\bin

SYSTEM VARIABLES
JAVA_HOME
C:\Program Files\Java\jdk1.5.0_04
PATH
D:\Oracle11\product\11.2.0\client_1\BIN
ORACLE HOME
D:\Oracle11\product\11.2.0\client_1\BIN
 
Tina Smith
Ranch Hand
Posts: 208
9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Type "java -version" at a command prompt and see what you get.


You might also try javac -version. In order for your program to work correctly, the major and minor versions (eg 1.5.x) of java must be at least those of javac.

The unsupported class version error isn't related to JDBC at all. (unless one of your libraries was compiled under a higher JDK than you're using, but even then it's not related to JDBC).

If the version of java is lower than javac, it's probably using the JRE Oracle provides rather than the JRE you think. Go take a look in D:\Oracle11\product\11.2.0\client_1\BIN and see if there's a "java.exe" there...
The solution would be to add java to the PATH environment variable BEFORE the Oracle entry. (Adding it after will have no effect).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic