I am trying to connect to Oracle 11g DB through my below java code, in an web application using Tomcat 4 server. ojdbc6.jar in Eclipse build path, but getting this below Error.
BUT when I tried this piece of same Java code in a Java file (public static void main()) and having ojdbc6.jar in Eclipse build path, it was able to connect to d DB, Very Strange!!
Then why this same code is not working in my web application??
Server: Tomacat 4
JDK Version: JDK 1.6
Java Code:
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:#hostName:portNum:SID","user", "pass");
Getting this below Error:
java.lang.ArrayIndexOutOfBoundsException: 7
at oracle.security.o3logon.C0.r(C0)
at oracle.security.o3logon.C0.l(C0)
at oracle.security.o3logon.C1.c(C1)
at oracle.security.o3logon.O3LoginClientHelper.getEPasswd(O3LoginClientHelper)
at oracle.jdbc.ttc7.O3log.<init>(O3log.java:289)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:251)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:246)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
Since your standalone program is running correctly, it means your program runtime classpath is fine. However for Tomcat 4 its failing which raises a suspicion on the tomcat classpath. My guess is that since your tomcat is pretty old, it might be containing old driver class (may be classes12.jar or older ojdbc jar file in libraries of your tomcat (especially look into the $CATALINA_HOME/common/lib). If that is the case remove all other jars except ojbdc6 from your classpath. Also make sure your web application libraries do not contain the classes12.jar or older ojdbc jars.
Also you can try to use -verbose:class in your tomcat jvm startup to print the information from where the classes are loaded. This will however output lots of information in the log files.Search for the driver class and it will show you where this was loaded from.
Loaded oracle.jdbc.driver.OracleDriver from file: xxx.jar
Related
I opened Oracle SQL Developer after using it for a while a few days ago and then I run into this mysterious and infuriating issue where I cannot connect to my locally installed database. First I got a report of the JDBC driver being outdated when testing the connection, so I replaced it with the updated version and then tried again, but then got a different error saying the OCI library won't load. The path to my Oracle Databse Express Edition 18 installation that works as ORACLE_HOME is C:\app\nicho\product\18.0.0\dbhomeXE. I don't understand why the OCI library won't load, as the oci.dll and associated oci files are all in the directory the error message specifies: C:\app\nicho\product\18.0.0\dbhomeXE\bin. I tried using the Instant Client option in the Tools->Preferences->Database->Advanced section by downloading the Oracle Instant Client and changing the path, but I got the same OCI library load failed message. This problem is very significant because I need to use this software for my college project and cannot do my work. I don't understand why this error is happening.
Testing the Oracle Home located at C:\app\nicho\product\18.0.0\dbhomeXE
Testing client directory ... OK
Testing loading Oracle JDBC driver ... OK
Testing checking Oracle JDBC driver version ... OK
Driver version: 21.1.0.0.0
Testing testing native OCI library load ... Failed:
Error loading the native OCI library
The native OCI driver could not be loaded. The system propertyjava.library.path contains the entries from the environment variable PATH. Check it to verify that
the expected native library directory C:\app\nicho\product\18.0.0\dbhomeXE\bin is present and precedes any other client installations.
java.library.path = C:\Users\nicho\OneDrive\Documents\IS 410\sqldeveloper\sqldeveloper\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\app\nicho\product\18.0.0\dbhomeXE\bin;C:\Users\nicho\AppData\Local\Microsoft\WindowsApps;;.
As you can see, the expected native library directory is in the path, but the OCI driver will still not load. My database and installation were working fine before today. Please help. :(
I have a Java application running and tested on my development workstation running Apache Tomcat 8. I have an established IBM i (AS/400) database connection working locally using the JT400.jar file. When I build and deploy the application to our production server running Apache Tomcat 8 with the same JT400.jar file, the database connection seems to fail and I cannot figure out why.
I get the following "HTTP Status 500 - Servlet execution threw an exception" error:
<code>
java.lang.AbstractMethodError
org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:913)
org.apache.tomcat.dbcp.dbcp2.PoolableConnection.validate(PoolableConnection.java:218)
org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.validateConnection(PoolableConnectionFactory.java:302)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:2164)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2147)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:1902)
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1412)
utilities.SerialSearch.doSearch(SerialSearch.java:81)
processes.ProcessScan.getSerialScreenDetail(ProcessScan.java:66)
processes.ProcessScan.ProcessScanRequest(ProcessScan.java:103)
controller.MetricServlet.performTask(MetricServlet.java:145)
controller.MetricServlet.doPost(MetricServlet.java:43)
javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
</code>
What is different and how do I resolve the issue?
Thanks!
I had the same error while using the current latest version (as of today 9.3).
The problem was that I was using the JDK 8, and using maven to fetch the package I received a version that was not appropriate for this JDK.
To solve this problem I used the proper maven qualifier:
<dependency>
<groupId>net.sf.jt400</groupId>
<artifactId>jt400</artifactId>
<version>9.3</version>
<classifier>jt400_jdk8</classifier>
</dependency>
Note that if you download the zip with the full suite, all version of the jar do have the same name (i.e. jt400.jar) which makes them hard to distinguish.
Problem solved. Rookie mistake. I inadvertently left the old jt400 jar files in the lib folder on the Apache Tomcat 8 server by renaming them. Once I deleted the old jar files my issues were solved with the new jt400 jar that I installed last week that started the conflict to begin with. Thanks!
This question already has an answer here:
Class [org.apache.derby.jdbc.ClientDriver] not found. When trying to connect to db
(1 answer)
Closed 7 years ago.
![JAVADB_DRIVER_LABEL library missing][1]
I am trying to connect to a JavaDB through netbeans 8 IDE on Windows 7. i can connect it using the DB manager provided with netbeans in Services panel. But when trying to connect it through my code I get ClassNotFoundException for the org.apache.derby.jdbc.ClientDriver class.
I could not run the Apache tomcat server on my machine, so I am Using the Glassfish server 4 that comes with netbeans.
my code to connect to the DB is as follows:
String url = "jdbc:derby://localhost:1527/sample;UID=app;PWD=app";
Class.forName("org.apache.derby.jdbc.ClientDriver");
conn = DriverManager.getConnection(url);
This similar code worked with SQL server, MS Access.
Please add your jdbc driver to the classpath of your project. It should work.
Currently, the class loader is unable to load your driver class as it does it does not find it in the classpath
Download the version of Apache Derby you need from here. Extract the zip and you should get derbyclient.jar which has the class org.apache.derby.jdbc.ClientDriver.
FYI : If your application runs on JDK 1.6 or higher, then you do not need to explicitly load the EmbeddedDriver. In that environment, the driver loads automatically.
You need to add derbyclient.jar to your classpath. You can find this jar in the download package of derby from here. This jar contains your org.apache.derby.jdbc.ClientDriver.
For more information, see this answer : where is org.apache.derby.jdbc.ClientDriver?
I wrote a java servlet program but when i run it, It was showing the Exception java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
My code
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(url, "username", "pass");
I am using Oracle 10.2.0. I added also ojdbc14.jar and ojdbc14_g.jar.
When I give the below command to command line. I get Error: Main method not found in class oracle.jdbc.driver.OracleDriver
I added also ojdbc14.jar and ojdbc14_g.jar
When adding third party libraries to your application, you must be sure they are in the Build Path of your application. In case of web applications, every third party library must be inside the WEB-INF/lib of the application so when deployed to the server (Tomcat, JBoss, etc.) they can be recognized and loaded when running your application.
Steps to rectify (if running from command prompt)
Step 1- Copy the ojdbc6 jar file from
C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib (Note- this path may differ as per the installation).
Step 2- Paste the ojdbc6 jar file in the Location
C:\Program Files\Java\jre1.8.0_45\lib\ext (Note- this path may differ as per the installation).
Step 3- Now run the programme java -cp . . It should successfully run without any error.
I need to connect to Oracle9,10 and 11 in my java application.The client will always be present where the app will be run and I want the app to just work with username,password and instance (specified in tnsnames.ora).Hence I would like oci drivers with a connection string of type : jdbc:oracle:oci:#testora .Im using the driver: oracle.jdbc.driver.OracleDriver.
I have a 10g client and am using jdk1.5. When I use the ojdbc14 jar from client lib path the app runs.
But if I use the ojdbc5 driver then the app fails with
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.
library.path
exception.
What im looking for is a way to package a single jar(ojdbc5/ojdbc14) and a single driver which will use oci drivers to connect to the client that is present on local machine(9/10/11).This is the way I would prefer it.
If this is not possible can I search the unix box for oracle version,pick up the correct jar and then use it in classpath when invoking the app which is in jar format?
Thanks,
Fell
java.lang.UnsatisfiedLinkError: no ocijdbc11 in java.library.path
This means that you are missing a DLL (ocijdbc11.dll) in the Java library path. Make sure you have that DLL and start your program like this:
java -Djava.library.path=C:\mydirwiththedll com.mypackage.MyProgram
ojdbc5.jar is intended to work with jdk1.5.x either you are connecting to Oracle 10 or 11g shouldn't matter, ojdbc14.jar was intended for jdk1.4.x