Problem registering jdbc driver in jar
My java oracle program runs fine as a class.
(java myclass)
But when I run the program as an executable jar (java -jar myclass.jar), a statement like
Class.forName("oracle.jdbc.driver.
OracleDriver"); throws the ClassDefNotFound exception, in other words it can not find and load the driver class !
Any solutions ?
Thanks
I had the same issue, as a work around I included classes12.zip (in my case) in a sub directory from my application /jdbc. Then added the following line to the manifest
Class-Path: jdbc/classes12.zip
Hope this helps
Similar Messages
-
Dynamically loading and registering JDBC driver from an archive (zip - jar)
I'm programming an JDBC driver tester.
I have to load dynamically any driver from an archive (jar or zip) after the user uploaded it.
I think i did it well with my ClassLoader, i can get an instance of the driver and use any method like (getMinorVersion()) but when i registering it fail.
There is no error but the driver is not registered.
I rode the DriverManager log (with his logwriter) and he says :
skipping: driver[className=oracle.jdbc.driver.OracleDriver,oracle.jdbc.driver.OracleDriver@5439fe]
skipping: driver[className=oracle.jdbc.driver.OracleDriver,oracle.jdbc.driver.OracleDriver@2b7db1]
(two times, it looks curious isn't it ?)
This is a part of my code :
Driver pilote = (Driver)Class.forName(driverClass.getName(), true,this).newInstance();
System.out.println("Minor Version = "+ pilote.getMinorVersion());
PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(System.out));
DriverManager.setLogWriter(printwriter);
DriverManager.registerDriver(pilote);
System.out.println("Driver registered\n");I have made a simple test :
public static void main(String[] param)
System.out.println("Loading Driver from JAR ...");
try
File jar = new File("c://mbm//drivers//oracle.jar");
URL aurl[] = {jar.toURL()};
URLClassLoader urlclassloader = new URLClassLoader(aurl, ClassLoader.getSystemClassLoader());
Class.forName("oracle.jdbc.driver.OracleDriver", true, urlclassloader);
PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(System.out));
DriverManager.setLogWriter(printwriter);
Enumeration listDriver = DriverManager.getDrivers();
System.out.println("[---------Drivers-----------]");
while (listDriver.hasMoreElements())
Driver driver = (Driver) listDriver.nextElement();
System.out.println("->> "+driver.getClass().getName());
catch (MalformedURLException e)
e.printStackTrace();
catch (ClassNotFoundException e)
e.printStackTrace();
This displays that :
Loading Driver from JAR ...
skipping: driver[className=oracle.jdbc.driver.OracleDriver,oracle.jdbc.driver.OracleDriver@9ec21d67]
[---------Drivers-----------]
D:\www\tomcat\webapps\mbm\WEB-INF\classes>
I think there is in this case only one instance -
Problem with JDBC driver for Oracle 10g
Hi.
I've successfully accessed a MySQL database via a DataSource from a servlet (that uses a DAO). However, when I try to do the same with an Oracle 10g Database, I get the error message:
Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
I'm using J2SE1.5.0/5.0 and ojdbc14.jar, the latter of which I downloaded this afternoon as the latest driver JAR available on the Oracle site. As with the MySQL driver, I've placed it in the commons\lib folder within Tomcat. (I've also, of course, made the necessary modifications to server.xml and web.xml.)
Upon examining the ReadMe file at the top of the Oracle download page, I found that the oracle.jdbc.driver package is now deprecated and all references to oracle.jdbc.driver should be replaced with oracle.jdbc. However, I got a similar error message when I tried this modification. Upon examining the contents of ojdbc.jar, I found that the driver was there and that it was, in fact, still oracle\jdbc\driver\OracleDriver!
It appears as though the Oracle site has not been updated with a driver that matches its latest documentation. However, this does not explain why the driver is not even being loacted when it is in the correct place. Can anybody shed any light on this? Any help would be much appreciated.
Thanks in anticipation.
Cheers.
JanI've successfully accessed a MySQL database via a
DataSource from a servlet (that uses a DAO). However,
when I try to do the same with an Oracle 10g
Database, I get the error message:
Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
That's different from a ClassNotFoundException.
>
I'm using J2SE1.5.0/5.0 and ojdbc14.jar, the latter
of which I downloaded this afternoon as the latest
driver JAR available on the Oracle site. So you got ojdbc14.jar or ojdbc14_g.jar under the 10g drivers?
As with the
MySQL driver, I've placed it in the commons\lib
folder within Tomcat. I think it's a better idea to put in the WEB-INF/lib directory of your Web app rather than commons/lib. WAR files are a very good idea, too.
(I've also, of course, made the
necessary modifications to server.xml and web.xml.)So you're using a JNDI data source? It sounds to me like that's where the problem is.
You should not have to edit the server.xml at all. If you put the <ResourceParams> in a context XML file with the same name as your WAR file into the TOMCAT_HOME/webapps directory it'll be picked up automatically. (It might also be accessible in the META-INF directory for your app, but I haven't done it that way.)
Upon examining the ReadMe file at the top of the
Oracle download page, I found that the
oracle.jdbc.driver package is now deprecated and all
references to oracle.jdbc.driver should be replaced
with oracle.jdbc.
However, I got a similar error
message when I tried this modification. Upon
examining the contents of ojdbc.jar, I found that the
driver was there and that it was, in fact, still
oracle\jdbc\driver\OracleDriver! The fully-resolved class name you should be using MUST match the class that's in the ojdbc14.jar that you're using. Look in the JAR for the definitive answer: the one that I downloaded is still using the oracle.jdbc.driver package for OracleDriver.class. Ignore the docs - use the name that's in the JAR.
It appears as though the Oracle site has not been
updated with a driver that matches its latest
documentation. That often happens with docs.
However, this does not explain why the
driver is not even being loacted when it is in the
correct place. Can anybody shed any light on this?
Any help would be much appreciated.I think the problem lies in your web.xml and server.xml
I'd recommend that you decouple the JDBC from the Web app for now. See if you can connect to Oracle using a simple desktop app and leave the Web piece out of the equation for now. Once you can do that, you'll be certain that the parameters you're using are correct and you can turn your attention to getting the Tomcat configuration right.
PS - I'm using Oracle 9.2.0.1 and Tomcat successfully right now, so it can be done. -
Problem using JDBC driver with JSP
Hi, I am trying to connecto to my mysql server via a JSP page, but it seems that there is a problem with the driver call or something in my configuration that unables me to connect. I have the mysql-connector-java-3.0.7-stable driver.
This is how my classpath looks like:
CLASSPATH=/home/hooper/Sources/mysql-connector-java-4.0.7-stable/lib:/home/hooper/Sources/mysql-connector-java-3.0.7-stable/com:/home/hooper/Sources/mysql-connector-java-3.0.7-stable/mysql-connector-java-3.0.7-stable-bin.jar:/usr/java/j2sdk1.4.1_02:.:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/usr/java/j2sdk1.4.1_02
And this is my JSP page code:
<%@ page language="java" import= "java.sql.*"%>
<%
Connection con = null;
String userName = "hooper";
String password = ""; //No password
String url = "jdbc:mysql://localhost/test";
//Load the Driver class file
Class.forName("com.mysql.jdbc.Driver");
//Make a connection to the MySQL database
con = DriverManager.getConnection (url, userName, password);
out.println ("Database connection established");
if (con != null){
//Close the connection
con.close();
%>
And this is the error I get from Tomcat4.1.18:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: com.mysql.jdbc.Driver
root cause
javax.servlet.ServletException: com.mysql.jdbc.Driver
I hope someone can help me with this.
Thanks,
LuisHi..
Try using this way
String userName = "hooper";
String password = ""; //No password
String url = "jdbc:mysql://localhost:3306/test";
Class.forName("org.gjt.mm.mysql.Driver");
try to download the driver for mysql and add it to your classpath
Hope this works
Regd
Vasi -
How to register jdbc driver in java application
Using Java Studio Enterprise:
1. Add mssqlserver.jar to Libraries.
2. jar contains package: com.microsoft.jdbc.sqlserver,
package contains SQLServerDriver.class
Trying to register this driver in program with:
Class.forName("com.microsoft.jdbc.SQLServerDriver");
raises exception ClassNotFoundException
Maybe I should put mssqlserver.jar to specific folder?
For web application using same driver works fine.hi,
Class.forName("com.microsoft.jdbc.SQLServerDriver");
raises exception ClassNotFoundExceptionFirst you check weather these jar files is in your lib <folder>
msbase.jar,mssqlserver.jar,msutil.jar
if no, copy that files and try it, -
How to delete a registered jdbc driver
I configured a third party jdbc driver but it's wrong. I tried to remove it but I can't find any way to do so. can any body tell me how to remove a defined jdbc driver(not remove a connection.) thanks.
Registered third-party JDBC drivers can be deleted or edited by opening the 'Preferences' dialog (select the 'Preferences' menu item from the 'Tools' menu) and selecting the 'Database Connections' item on the left-hand tree. The resulting panel has a list of the registered drivers; select the one you wish to delete and click the 'Delete' button.
- John McGinnis
Oracle JDeveloper Team -
Problem loading jdbc driver in Tomcat
Hi,
I have got a connection to MySQL5.0 from TomCat 5.5.13, that was test correctly in development (JSC Upd 1) but I encounter the following deployment error :
com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
When I verify, I found that if I put the mysql Connector JDBC driver in <tomcat>/common/lib, there is no error.
But when the MySql Connector JDBC driver resides in <tomcat>/shared/lib, the error persists.
What's the difference ? shouldn't it work for both ?
Thanks in advance for any pointers and advise.hmm... i guess that it's a must to include the lib at /common/lib instead of shared/lib .
Is there a Tomcat resource that I can read up on ?
rgds -
How to register jdbc Driver in Applet
Dear Sir,
i am running a applet through jsp
i am using following softwares
jakarta-tomcat-4.1.10
mysql 3.23.52-max
jsp
j2sdk1.3.1
Linux 7.3
Netscape 4.*
the problem is when i am trying to load the applet in jsp
<jsp:plugin type="applet" code="XX" width="XX" height="XX">
</jsp:plugin>
it gives following message
the page contains information of type
(application/x-java-applet;jpi-version=1.4) that can we viewer with
appropriate Plug-in , so i am using applet tag
but it is running fine in browser if i give .html extension
the other problem is , my normal jsp are running and getting connected to Mysql
but when i use applet it is giving error ClassNot Found Error, i have included jar
file mysql-connector-java-3.0.1-beta in my class path
do i have to install the jar file on the client m/c as applet runs on client m/c
how to register driver in Applet
thank you
sunilI'm not sure about the jsp page thing but to get your mysql working in the applete what you need to do is in the <Applete> tag where you have archive=myclass.jar add this to it archive="myclass.jar, mysql-connector-java-3.0.1-beta.jar"
make sure the mysql...jar is in the same dir as your jar file and the database server is on the same machine. It won't let you connect from an applete to a database that's on a diffrent machine. You'll get an access denied error.
For the jsp page try putting your class as the code="my.class" and add archive="same stuff to fix <Applete>"
that might work.
Hope I gave you enough info to get you on the right track.
Matt S. -
Problem with JDBC driver for mysql
I have downloaded the Connector/J3.0 mysql-connector-java-3.0.7-stable.tar.gz from www.mysql.com/downloads/api-jdbc-stable.html web site and used gunzip and tar to extract the file. I have received the following error message:
tar: directory checksum error
Will this error cause some problem later on?
Which directory should I put the driver into? Can I put it in any directory?
Do I need to set the classpath for the driver? If yes, how can I set it?
What is the connect string? Can you give a sample for me? I am using Solaris 5.8 and mysql is on the same machine.
Thanks a lot,
Lisathis is an example of a connect string for mysql that i used...
public Connection CreateConnection () throws Exception
Connection myConn = null;
String driverName = "org.gjt.mm.mysql.Driver";
String dbUrl = "jdbc:mysql://www.desres.com/jhazrd?user=jhazrd&password=????";
Class.forName(driverName);
myConn = DriverManager.getConnection (dbUrl);
return myConn;
} -
CachedRowSet Problems for JDBC Driver
Hello Joe,
I've encounting the same problem.
Can you tell me how can I get your hacked version of driver?
Thanks,
Howard
Joseph Weinstein <[email protected]> wrote:
I'll send it to you.
Joe
Andrew Zarudnev wrote:
Joseph Weinstein <[email protected]> wrote:
I'll send you the driver.
JoeHello Joe,
I've encounting the same problem.
Can you tell me how can I get your hacked version of driver?
Thanks,
Andrew
Eugen Bulboaca wrote:
Hi Joe,
I've hacked a
new version of our driver that simply returns "" instead of
null for the relevant functions, and that seemed to help
the original requestor. Anyone who wants it let me know...I just discovered the problem within our software and now I'm looking
for a quick (a REALLY quick soluction, because we have to make a demo
in a couple of days :( )... I just read the Javadoc for the interface
ResultSetMetaData, and it does specify that it <<returns schema name
or "" if not applicable>> for getSchemaName(). So, can you help me with
that version of the driver you updated ?! Thanks ALOT !!
Eugen--
PS: Folks: BEA WebLogic is in S.F., and now has some entry-level positionsfor
people who want to work with Java and E-Commerce infrastructure products.Send
resumes to [email protected]
The Weblogic Application Server from BEA
JavaWorld Editor's Choice Award: Best Web Application Server
Java Developer's Journal Editor's Choice Award: Best Web ApplicationServer
Crossroads A-List Award: Rapid Application Development Toolsfor Java
Intelligent Enterprise RealWare: Best Application Using a ComponentArchitecture
http://www.bea.com/press/awards_weblogic.html--
PS: Folks: BEA WebLogic is in S.F. with both entry and advanced positions
for
people who want to work with Java and E-Commerce infrastructure products.
Send
resumes to [email protected]
The Weblogic Application Server from BEA
JavaWorld Editor's Choice Award: Best Web Application Server
Java Developer's Journal Editor's Choice Award: Best Web Application
Server
Crossroads A-List Award: Rapid Application Development Tools for
Java
Intelligent Enterprise RealWare: Best Application Using a Component Architecture
http://www.bea.com/press/awards_weblogic.html -
Problem In JDBC Driver Package Class12.zip
After executing the code below:
Connection con = ConnectionPool.getConnection();
while(true){
Statement sta = con.createStatement();
sta.close();
Exception is raised after the loop is executed 300times with message:
ORA-01000: ³¬³ö´ò¿ªÓαêµÄ×î´óÊý
then I checked the connection,and found that it is not cloed but cannot createStatement any more.
what't the matter with it?in fact every statement is closed properly.Clark,
I'm only guessing, but it could be that the "close()" method returns before the database has actually released the resources associated with the "Statement" you are closing. In that case you are probably creating "Statement"s faster than you are closing them, and hence the ORA-01000 error (I think :-)
Good Luck,
Avi. -
Oracle jdbc driver problems in netbeans 5.5
need help again....i'm experience a problem. the problems are :
i connect from netbeans 5.5 to oracle database express client 10g using jdbc driver ojdbc14.jar. the connection succeded (all the tables appears and i even can view the data). but when i trying to bind data to a drop down list component (with right click to the dropdown list component and then bind data), the dataprovider of that table appear in red color and there's no field appears in that. i'm so confused? i already add the ojdbc14.jar driver to the following path :
1. i create a new class library in netbeans with consist of that driver,
then added to my project (right click in my project then add library).
2. then i added the ojdbc14.jar driver to my tomcats lib at "C:\Program
Files\netbeans-5.5\enterprise3\apache-tomcat-5.5.17\common\lib".
Is there any additional settings in using oracle jdbc driver? Does anyone knows? thanks a lot for the answers...
Message was edited by:
darma_sadhaHi!
I'm using NetBeans 6.5 and I'm having some troubles to connect.
The steps I've made:
- Create the connection pool in Glassfish, nothing special, just standard parameters (Based on javax.sql.DataSource and including URL, Username and Password).
- Create the JDBC resource associated with that connection pool,let's say jdbc/test.
Now in NetBeans I register the driver:
- New driver -> Find the ojdbc14.jar and from the options that I can choose it shows: oracle.jdbc.OracleDriver and oracle.jdbc.driver.OracleDriver.
If i choose without +.driver+ I got the thin drivers (the ones i want) and if i chosse the one with the other one I got the OCI drivers. So I choose the first option oracle.jdbc.OracleDriver
- Then I go to my project and click New -> Entity Classes from Database and from Datasource I select jdbc/test and it shows the following error message:
Unable to find the driver oracle.jdbc.driver.OracleDriver. Please register this driver in the Databases.
I can fix it if while registering the ojdbc14.jar I select the second option (*oracle.jdbc.driver.OracleDriver*) but with this option I need to specity the connection to use OCI instead of the desired thin driver.
I hope you'll understand and help me somehow
Edited by: KILE on Oct 10, 2008 2:26 AM -
Tomcat7 + JDBC driver jar
Context:
According to the installation guide for bonitasoft (http://documentation.bonitasoft.com/dat … add_driver)
Tomcat 7
For Tomcat, simply add the JDBC driver jar file in the appropriate folder:
Bonita BPM Tomcat bundle: in the bundle folder add the driver to the lib/bonita folder.
Bonita BPM deploy bundle: in the Tomcat folder add the driver to the lib folder.
Ubuntu/Debian package: add the driver to /usr/share/tomcat7/lib.
Windows as a service: add the driver to C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib
Problem:
Which JDBC driver is meant ? I searched the web for an tomcat JDBC jar file for tomcat7 ?
This confused me further, I tought archlinux is analog to ubuntu and read the section platform installation example for (Ubuntu + OpenJDK + Tomcat + MySQL):
Add JDBC driver
You need to include JDBC driver in Tomcat classpath:
Change to Tomcat libraries directory: cd /usr/share/tomcat7/lib.
Download the library mysql-connector-java from the MySQL site to this directory.
But the mysql site (recommended by the installation guide) provides a download link for an tar.gz file and on google.code (https://code.google.com/p/find-ur-pal/d … 8-bin.jar&) I found .jar file. The installation guide clearly speaks about an .jar file. There are different version of the JDBC jar file on the web. Which one is right ?Do you intend on continuing to spam the boards with this issue? Read the Etiquette and the wiki: https://wiki.archlinux.org/index.php/Tomcat_and_Apache
Moving to NC... -
Oracle jdbc driver class and classes12.jar whether deprecated.?
Hi All,
1. In one of the post, it has been told that oracle.jdbc.driver.OracleDriver will be deprecated and also recommended to used oracle.jdbc.OracleDriver.
According to that post, I changed the driver class name in my code as below:
Class.forName("oracle.jdbc.OracleDriver");
Then to check the driver name, I insert the below code:
Enumeration<Driver> driverEnum = DriverManager.getDrivers();
+while (driverEnum.hasMoreElements()){+
System.out.println("driver : "driverEnum.nextElement());+
+}+
Below is the output:
driver : oracle.jdbc.driver.OracleDriver@addbf1
Even after specifying the driver class name to be used as oracle.jdbc.OracleDriver, why it is taking oracle.jdbc.driver.OracleDriver..?
INFO : The Oracle JDBC Driver (classes12.jar) version is 10.2.0.4.0.
2. We are using classes12.jar for developing all JDBC code. In Oracle Database 11g Release 2 (11.2.0.2.0) JDBC Drivers, there is no classes12.jar. Is this deprecated? Which jar can be used instead of classes12.jar?
Thanks in advance.In Oracle Database 11g Release 2 (11.2.0.2.0) JDBC Drivers, there is no classes12.jar. Is this deprecated? Which jar can be used instead of classes12.jar?For JDBC 4.0 features ojdbc6.jar with JDK 6.0.
For JDBC 3.0 support ojdbc 5.jar with JDK 5.0
http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html -
I'm having problems registering jdbc drivers. I've been trying to register the microsoft Sql Server 2000 jdbc driver so that I can create a connection in my code rather than using entity beans. I've set the CLASSPATH variable to point to the driver's .jar files in the install directory with no success.
I've connected to the database using the driver via the IDE' s Runtime and it tests ok and allows me to create a database schema ok. (I had to copy the driver files to the sun/studio5u1_se/lib/ext dir to enable this) Is there a location I can unpack the drivers .jar files which will make the driver available?
I have also tried setting the CLASSPATH variable to point to the above mentioned directory..but that didn't work either. Can anyone help?
These are the exception messages that I get
java.lang.ClassNotFoundException: com.pointbase.jdbc.jdbcUniversalDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at Portfolio.DriverTest.getConnection(DriverTest.java:43)
at Portfolio.DriverTest.main(DriverTest.java:102)
Error Trace in getConnection() : com.pointbase.jdbc.jdbcUniversalDriverIf u type in command line
java -classpath .;<directory containing the driver>
it executes your class file properly
note that <directory containing the driver> is the full path to your driver. I mean, the directory that contains your driver\drivername
eg:
java -classpath .;c:/driver/drivername
don�t forget to put the "dot" before semicolon. If u forget it, java won�t find your class file. your class file must be at the directory you�re executing the command
I need to configure my sun studo ent. to locate my jdbc driver for mySQL. I don�t know where this can be made. If any of you know. please report me
Maybe you are looking for
-
Variable based on calender dashboard prompt does not show in the report
hello, i have at the dashboard a calender prompt for a column of date format and a pres variable for that value ('DAY'); i placed in the report a column of which content (fx) is @{DAY}; when i run the report the value of my variable is 0 instead of c
-
Looking to move the maintenance of our IDS instances which drive Documaker MRLs from the Unix command line to within a container ( Websphere ). Using the IDS Java client with JMS is pretty easy. I cannot see how I would be able to get an IDS server
-
When I deploy the cube which is sitting on my PC (local) the following 4 errors come up: Error 1 The datasource , 'AdventureWorksDW', contains an ImpersonationMode that that is not supported for processing operations. 0 0 Error 2 Errors in the high
-
Good morning, I have 2 questions..... #1.... Can I receive the same kind of programing I'm currently paying for through Satellite? #2.... I would like to be able to choose which networks I view, ( pay for, and support )? What I mean by that is..... c
-
SRM- Error required in English language
Presently error message is being presented in both English and Dutch language. Is there any setting in SRM by which errors can only be displayed in English language for users in US plants.