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

Similar Messages

  • Can't load jdbc driver from localhost

    I'm having problems loading the jdbc driver from localhost when using a java com object in ASP.
    The simple class compiles fine and runs perfect from dos command line but gives this exception when run from personal webserver:
    java.lang.ClassNotFoundException: sun/jdbc/odbc/JdbcOdbcDriver
    Obviously, it is not finding the jdbc driver, but what is the problem? It finds the driver when run from dos locally. Do I need a 3rd party driver when using as a COM object?
    Here is a code snippet:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection TestConnection = DriverManager.getConnection("jdbc:odbc:systemDSN", "username", "password");
    Any help is appreciated, thanks!

    I don't think it's exactly a classpath problem. I think when you run from the DOS command line, you are using the java.exe program that contains Sun's JVM and all the associated classes including sun/jdbc/odbc/JdbcOdbcDriver. But when you use this Java COM object (which I am not familiar with), if it doesn't find that class then it must be using the Microsoft VM, which naturally doesn't include that class you are having a problem with.

  • Find the difference between loading and registering the drivers..

    Dear Sir..
    Could you please help me to find the difference between two activities..
    1.Loading the drivers
    2.Registering the drivers
    What's the difference between loading and registeing the drivers and what activities take place by the JVM to do it all.

    Dear Sir..
    Could you please help me to find the difference
    between two activities..
    1.Loading the drivers
    2.Registering the drivers
    What's the difference between loading and registeing
    the drivers and what activities take place by the JVM
    to do it all.You load a class - it isn't specific to a driver.
    That is part of java - not JDBC.
    Normally JDBC drivers register themselves when the class is loaded. This is specific to the driver and has nothing to do with a user of the driver. It is only a concern to someone who must implement a driver.

  • On an ipod touch 4th generation, how do I load and sync my music from the computer to the ipod without mixing up and/or losing all of my photos which I have in categories?

    On an ipod touch 4th generation, how can I load and sync my music from my computer to the ipod without losing and/or mixing up my photos which I have put into categories?

    Finally did somethign that fixed this.  I restored my hard drive.

  • Error oracle.sql.* and oracle.jdbc.driver.* not found when using oracle as a database

    I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
    Please Advice!
    Thanks in advance
    AnuPama

    Hi Anupama,
    First of all I would be surprised if you would not like to use the connection pooling feature of weblogic (in which case you might not be needing the import the classes directly), and would like to open direct connections to your database. Anyways for doing that I would recommend you to check out the readme doc that ships
    along with the jdbc oracle (classes12.zip etc). I am giving an excerpt over here:
    These are a few simple things that you should do in your JDBC program:
    1. Import the necessary JDBC classes in your programs that use JDBC.
    For example:
    import java.sql.*;
    import java.math.*;
    2. Register the Oracle driver before before calling other JDBC APIs.
    (This is not needed if you are using the JDBC Server-side Internal
    Driver because registration is done automatically in the server.)
    To register the Oracle driver, make sure the following statement
    is executed at least once in your Java session:
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    3. Open a connection to the database with the getConnection call.
    Different connection URLs should be used for different JDBC
    drivers. The following examples demonstrate the different URLs.
    For the JDBC OCI8 Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:oci8:@<database>",
    "scott", "tiger");
    where <database> is either an entry in tnsnames.ora or a SQL*net
    name-value pair.
    For the JDBC Thin Driver, or Server-side Thin Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@<database>",
    "scott", "tiger");
    where <database> is either a string of the form
    <host>:<port>:<sid> or a SQL*net name-value pair.
    For the JDBC Server-side Internal Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:kprb:");
    Note that the trailing ':' character is necessary. When you use
    the Server-side Internal Driver, you always connect to the
    database you are executing in. You can also do this:
    Connection conn
    = new oracle.jdbc.driver.OracleDriver().defaultConnection();
    Hope this helps,
    Thanks,
    Anupama wrote:
    I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
    Please Advice!
    Thanks in advance
    AnuPama--
    Apurb Kumar

  • IChat randomly loads and wakes my machine from sleep.

    iChat has been randomly loading and waking my machine from sleep. I can even be sitting in front of it and suddenly it will load and log me in AIM. Seems very virus like, but not sure it is. Anyone know what's going on?

    Here's a more detailed description of what's happening.
    After upgrading to 10.5.1, my iChat will load automatically at random times. It will even wake the computer out of sleep to load it. I was really frustrated that this was happening, and believing it was from having upgraded from 10.4, I decided to format my computer. After a clean wipe and updating to 10.5.1, iChat again is loading by itself randomly. I can quit iChat and go away for 30 minutes, come back, and it's launched again.
    I have noticed on occasion when my iPhone is connected via the USB port that when it receives an e-mail it has been prone to launching iTunes and iChat, so this problem might be inter-related. However, I can have my iPhone disconnected and iChat will still load by itself. In fact, I quit out of iChat this morning, came to work and loaded iChat here at the office and it said I was logged in at another location. It must have logged in again at home. It's never done this in any other OS version for me.

  • Web logic cann't load Sql Server jdbc driver

    Web logic cann't load Sql Server jdbc driver. I've got an exception:
    NoClassDefFoundError: com/microsoft/sqlserver/jdbc/ISQLServerConnection
    but sqljdbc.jar is in weblogic's library directory.

    Hi,
    You can find Oracle Support id 1503650.1 (https://support.oracle.com) with the solution.
    Arik

  • Loading JDBC-Driver from a JSP

    Hi,
    i want to load a JDBC-Driver fromout my JSP-File, so i used:
    Class.forName("org.postgresql.Driver");
    but when i start it i get a ClassNotFoundException...
    my jsp-file and the org-directory are stored in
    <tomcat-dir>\webapps\examples\
    so both in the same directory...
    any ideas why i cannot load it?
    thx anyway
    cu Errraddicator

    it still does not work...
    now i can load the driver, but when i call the DriverManager to establish a connection i get a sqlexception with the message "no suitable driver"...
    but why? i�ve loaded the driver and normally it registeres itself at the driver-manager, but it doesn�t...
    any ideas?
    thx anyway
    cu Errraddicator

  • Cannot load external Oracle JDBC driver in JEE5 server

    Hi experts,
    I installed CE 7.1 SP3 downloaded from SDN.  I developed a EJB using JPA and wanted to connect an external Oracle 10 database.  I firstly tried to create a JDBC driver resource in NetWeaver Adminstrator (nwa).  The nwa page showed that load the ojdbc14.jar successfully.  But when I checked the status on the nwa page, it shows that the status is unknown. 
    Any idea?  Thanks in advance.
    Regards,
    Ken

    Hi Ken,
    > Both drivers doesn't working with 'Open SQL'. I get
    > the message "you must register your tables using
    > JDDI'.
    Open SQL works on a logical database catalog called Java Dictionary. Therefore, Open SQL requires that all database tables are created through the Java Dictionary.
    Please use the table editor contained in the Java Dictionary Perspective of the NWDS. You create the database tables by deploying a Dictionary archive.
    Best Regards,
    Adrian

  • 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
    sunil

    I'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 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

  • 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

  • PI 7.1 and Oracle JDBC driver: missing com.sap.aii.adapter.lib.sda

    Hello,
    I want to deploy the JDBC driver for Oracle databases as described in OSS 1138877 on a brand-new PI7.1 (SP06 Stack) installation. Unfortunately, I can't find com.sap.aii.adapter.lib.sda on the system, so I can't add the ojdbc14.jar file and deplay it using JSPM.
    Where can I get it from?
    Thank you and best regards,
    Herwig

    hey,
         The JDBC driver installation is different for PI 7.1.
    The dowload/modify/deploy .sap.aii.adapter.lib.sda method was used in the earlier versions.(mentioned in the How to guides)
    Look at the SAP documentation below -
    http://help.sap.com/saphelp_nwpi71/helpdata/en/cf/128a42f802a01ae10000000a155106/frameset.htm
    Arvind R

  • Calling Oracle JDBC Driver from JSP

    I have Apache Tomcat installed under Win2000 and can run simple JSP
    pages without any problems. I have installed Personal Oracle 9.0.1.0.1 on my win2000 PC and I can login using sqlplus as scott/tiger. The database is up.
    But when I try to access an Personal Oracle DB from a JSP page I get the following
    exception:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    root cause
    java.sql.SQLException: Io exception: Bad packet type
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Here is my JSP program:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@page language="java" import="java.sql.*"%>
    <%
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@<my host PC name>:8080:shark","scott","tiger");
    Statement stmt = conn.createStatement ();
    stmt.close();
    // Close the connection
    conn.close();
    %>
    Does anyone know why this error is showing up?
    Thanks

    Problem has been resolved. I did not have the Personal Oracle DB Listener running and the port needed to be changed to 1521 on the JSP program.

  • How to deploy MS Sql Server 2005 and 2008 jdbc driver

    Hi SAP Guru's
    Can somebody tell me how to deploy the jdbc driver of MS SQL Server 2005 and 2008 on SDM.
    According to the SAP instruction we should have 3 files(mssqlserver.jar,msbase.jar,msutil.jar) but in 2005 driver file we only have 1 file i.e sqljdbc.jar so how do i deploy it .
    Secondly i cannot deploy it on visual administrator as well and when i am doing the File to jdbc scenarion i am getting this error
    " Accessing database connection "jdbc.sqlserver://localhost:1433;DatabaseName=Employee failed DriverManagerException. Cannot establish connection to URL jdbc.sqlserver://localhost:1433;DatabaseName=Employee  SAPClassNotFoundException com.microsoft.sqlserver.jdbc.SQLServerDriver".
    can somebody please upload the screen shots on mediafire or any other site so that i will solve my problem.

    Hello,
    *OS: First of all: *
    3 files (msbase.jar,mssqlserver.jar and msutility.jar )should be zipped to aii_af_jmsproviderlib.zip file only for UNIX OS.
    For Windows OS only sqljdbc.jar file which in every version of JDBC driver should be zipped to aii_af_jmsproviderlib.zip.
    You can deploy JDBC driver through SDM tool which mention in guide below:
    New version of JDBC driver installation guiade:
    External Driver Configuration for Process Integration 7.0
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60237e74-ef19-2b10-5a9b-b35cc6a28e83
    Drivertool from this guide you can find at https://www.sdn.sap.com/irj/sdn/howtoguides
    Then Exchange Infrastructure How-to Guides for SAP NetWeaver 2004 HYPERLINK "https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f04ce027-934d-2a10-5a8f-fa0b1ed4d88f"
    How to Install and Configure External Drivers for JDBC & JMS
    AdaptersHYPERLINK "https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e00262f5-934d-2a10-b99c-9bc63c2a7768"
    Download attached system files (ZIP 16KB)
    Any questions - let me know
    BR,
    Dzmitry

Maybe you are looking for

  • T410 power on password problem

    hi, i have a t410. it was working normally. i removed the keyboard for a reason, then place it again. After that, i powered on and black screen appeared with a small lock icon upper left, requesting password. as far as searching on google, it should

  • Backspace button dead

    My backspace has decided to stop working yesterday night. I have got a feeling that some drops of water may have gone into the keyboard. Do you know if this can be repaired taking the laptop to an Apple store? Can you plase advise? Thanks

  • Email Bursting Maximum emails

    Hi Guys, Can anybody let me know what is the maximum limit of emails we can sedn via email bursting at one time? Is precalculation server is being used in doing email bursting or not for query brodcast? Pls advise. We are planning to implement email

  • Duplicated icons

    I have somehow duplicated my iphoto icon. It is on the dock and outside of the dock. when I move one to the trash I can no longer open iphoto. any suggestions?

  • Director MX 2004: Cursor Error

    I have a project that has many text fields to each page. Most of the cursors work in the text box. Some do not. I cannot see the cursor, therefore I cannot see what position the cursor is in so I can edit the field. Does anyone know of this issue. Pl