Application that handles multiple jdbc drivers. How to load driver classes?

Hi all,
I have a question that arised now while I am developing an application that handles different jdbc drivers.
Do I have to reload the driver class when I want to use a different jdbc driver?
Does DriverMAnager return connection of the last loaded jdbc driver?
thank you in advance, Kostas

No.
No.
Read the docs:
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DriverManager.html
which says in part:
"When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application."
In other words, getConnection inspects the provided database URL and tries to find a driver that can handle the URL.
I've had no problems with a program that uses bothe Oracle and MySQL at the same time, alternately reading from one and writing to the other.

Similar Messages

  • Calendar app that handles multiple Google calendars?

    Can anyone recommend a calendar app that handles multiple Google calendars in a single account, including one of what  Google's desktop web site shows as  "My calendar" calendar plus one "Other calendar" calendar?
    Thanks.

    Calendar can have two or more calendars calendars listed at the same time.
    Each can be a different color for identifidation.
    The first screenshot shows that the Medical and Joint calendars are shared calendars.
    Will that work for you?

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How to Load a class manually

    Hello Friends,
    I need a help regarding how to load a class manually.
    i have the class name -- TestClass1
    and Path - com.apps.classes
    Thank you

    Thank You------
    I got the result
    String classPath = com.apps.className;
    Object obj = Class.forName(classPath).newInstance();

  • How to use Multiple JDBC Drivers?

    Hi,
    I'm working with an application that connects to an Oracle 8 database and Oracle 10 databases as a single user/schema and then the application users all share the single Oracle user. When we use an Oracle 8 JDBC driver, then a module that inserts a large number of records (1500+) into an oracle table behaves inconsistently and either times out, pauses inserting records for exactly 1 hour, or throws an error. It also seems somewhat inconsistent from user to user.
    The problem goes away when we use an Oracle 10 or Oracle 11 JDBC driver. However, the Oracle 10 JDBC driver has a problem with truncating the hh:mi:ss from datetime column types to 00:00:00. This is a known Oracle error and I know there is a flag that can fix this with the Oracle 10 driver. However, with the way the JDBC driver gets installed in the application, we are unable to set that flag.
    Oracle 11 JDBC driver also doesn't have the Oracle 8 issue inserting a large number of records. However, we need to connect to an Oracle 8 database and Oracle 11 JDBC does not support that. The database is still active but being retired soon so no chance of upgrading to a newer Oracle version.
    I asked on the application forum (it's SAP Manufacturing Intelligence and Integration - MII) and was told the following. Data Server is a name for the connection to the database.
    "If the class packages are the same (assuming so since all of the oracle drivers I've seen use the same driver) then you can't have 2 at the same time, since they will overlap and you can't prioritize or point one data server to 8 and the other to 11."
    My experiments with trying to use two drivers have also shown this to be the case for what I tried.
    Any ideas or thoughts of how to make this work? We are using a JDK 1.5.
    Thanks for the help.
    Kerby Johnson

    The most reliable way would be to load each driver (and all code using it) using its own classloader.
    But that would likely be overly complicated.
    The most viable solution will likely be (especially as this is a short term project, you say it's going to be retired soon) to ensure a commit after every smaller subset of the total data volume and keep using the Oracle 8 drivers.
    Try forcing a commit after say every 100 records and see if you still have the timeout problems. Most likely this will take care of your problems at the cost of a slight performance decrease (but better somewhat less than optimal performance than risk database corruption or crashing applications, right?).

  • How to load a class dynamically (via reflection) in a jsf-component

    Hi all,
    I am writing my own jsf component and I would like to do it generically. Therefore I have an attribute, where the developer can pass a fully qualified classname, which I want to use to instantiate. But I have a Problem with the classloaders, everytime I get a ClassNotFound-Exception during debugging.
    Does anybody know how it is possible, to to get the most parent classloader?
    Currently I am even not able to load a class, which is in the same package like all other compontent-classes.
    Thank you very much in advance
    Thomas

    Within web applications, I believe it is recommended to use Thread.getContextClassLoader(). Keep in mind that web applications require different classloader semantics than regular Java applications. The class loader which gets resources from the WAR is favored over others, even when this violates the normal class loading conventions.

  • How to load parent Class like this?

    I have a java application that use another class in a jar file. And there is a class in the application's main class extends the class in the jar file. I have packaged the application into a jar file.
    the directory structure :
    foder [dist] : app.jar [lib]
    foder [lib]: Library.jar
    (I excute "java" cmd in folder "dist" )
    Now i can run it, if i use command line option -Xbootclasspath/a:
    "java -Xbootclasspath/a:lib/lib.jar -jar app.jar"
    (Because if i use "java -jar ", "-cp .;lib/Library.jar" option have no effect.)
    But I don't konw how make it run by codes.I tried this:
    Main.javapackage myapp;
    java.net.URL liburl = new java.io.File("lib\\Library.jar").toURL();
    java.net.URLClassLoader loader =
            new java.net.URLClassLoader(new java.net.URL[] { liburl });
    Class c = loader.loadClass("mylib.parentclass");
    Object    parentobj = c.newInstance();
    //c = loader.loadClass("myapp.subclass");  //can't run
    //Object    subobj  = c.newInstance();
    subclass.javapackage myapp;
    subclass extends parentclass{
    }parentclass.javapackage mylib;
    public class  parentclass{
    }the code Object    parentobj = c.newInstance(); can excute without problem . parentclass's constructor excuted.
    but
    c = loader.loadClass("myapp.subclass");
    Object    subobj  = c.newInstance();can not excute and without any exception throw out.
    I used the "-verbose:class" option , the output is:
    [Loaded java.lang.ClassFormatError from shared objects file] <---the last line
    Thanks for reading and participating .
    Please help me or point me to resources where I can read .
    Sorry for my poor english.
    thanks a lot .

    The problem is that when a class wants to resolve a reference to another class (e.g. when a class fetches it's parent) it uses the classloader that loaded it, which is not necessarilly the classloader from which it was requested.
    When you ask a standard classloader (e.g. URLClassLoader) for a class the first thing it tries is asking it's parent class loader. Only if the parent doesn't find the class does it try itself.
    So, if a class is available to the system ClassLoader then even though you ask a URLClassLoader for it, it's the system ClassLoader which actually loads it and, hence, it's the system ClassLoader that class uses to resolve any references.
    ClassLoaders generally form a kind or heirarchy and references can be made towards the root of the ClassLoader tree, but not in the other direction.
    You would have to do something like have a small main class which sets up the classloader and make your real main class available only on the jars that the URLClassLoader adds to the classpath. That way the main class will have the URLClassLoader as its ClassLoader and will use it to get it's parent class.

  • How to Load a class file base on .class file name???

    Hi,
    Can anyone help me?
    1) Based on filename (d:\temp\bla.class), I want to load this bla.class and get the actual package of this class.
    example:
    package something.temp;
    public class bla
    I want to load the file base on filename and get the package of the class. Is it possible ?
    Thank you.

    Hi nikki96,
    It will not work. I will get java.lang.NoClassDefFoundError eventhough I extends classloader to use the findClass(String filename);
    Example:
    import java.security.*;
    import java.util.Enumeration;
    import java.util.NoSuchElementException;
    import java.util.jar.Attributes;
    import java.util.jar.Manifest;
    import sun.misc.Resource;
    import sun.misc.URLClassPath;
    public class MyURLClassLoader extends ClassLoader
    String host;
    int port;
    public Class findClass(String name)
                   try
         byte[] b = loadClassData(name);
         return defineClass(name, b, 0, b.length);
                   } catch(Exception e)
                        e.printStackTrace();
                   return null;
    private byte[] loadClassData(String name) throws Exception
                   // load the class data from the connection
                   File file = new File(name);
                   InputStream is = new FileInputStream(file);
                   long length = file.length();
                   // You cannot create an array using a long type.
                   // It needs to be an int type.
                   // Before converting to an int type, check
                   // to ensure that file is not larger than Integer.MAX_VALUE.
                   if (length > Integer.MAX_VALUE) {
                        // File is too large
                   // Create the byte array to hold the data
                   byte[] bytes = new byte[(int)length];
                   // Read in the bytes
                   int offset = 0;
                   int numRead = 0;
                   while (offset < bytes.length
                        && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
                        offset += numRead;
                   // Ensure all the bytes have been read in
                   if (offset < bytes.length) {
                        throw new IOException("Could not completely read file "+file.getName());
                   // Close the input stream and return bytes
                   is.close();
                   return bytes;
    Problem: The class file is not in the proper package (d:\temp\bla.class) where the proper package is d:\something\temp\bla.class.
    Objective: I just want to base on the bla.class (no matter where is it located), then get the package of the classfile (bla.class) like example something.temp.
    Simple as that but I don't know how to do :(.

  • How to load a .class file dynamically?

    Hello World ;)
    Does anyone know, how I can create an object of a class, that was compiled during the runtime?
    The facts:
    - The user puts a grammar in. Saved to file. ANTLR generates Scanner and Parser (Java Code .java)
    - I compile these file, so XYScanner.class and XYParser.class are available.
    - Now I want to create an object of XYScanner (the classnames are not fixed, but I know the filename). I tried to call the constructor of XYScanner (using reflection) but nothing works and now I am really despaired!
    Isn't there any way to instantiate the class in a way like
    Class c = Class.forName("/home/mark/XYScanner");
    c scan = new c("input.txt");
    The normal call would be:
    XYLexer lex = new XYLexer(new ANTLRFileStream("input.txt"));The problem using reflection is now that the parameter is a ANTLRFileStream, not only an Integer, as in this example shown:
    Class cls = Class.forName("method2");
    Class partypes[] = new Class[2];
    partypes[0] = Integer.TYPE;
    partypes[1] = Integer.TYPE;
    Method meth = cls.getMethod("add", partypes);
    method2 methobj = new method2();
    Object arglist[] = new Object[2];
    arglist[0] = new Integer(37);
    arglist[1] = new Integer(47);
    Object retobj = meth.invoke(methobj, arglist);
    Integer retval = (Integer)retobj;
    System.out.println(retval.intValue());Has anyone an idea? Thanks for each comment in advance!!!

    Dump all of your class files into a directory.
    Use the File class to list all files and iterateover
    the files.NastyNot really, when you are dynamically creating code, I would expect the output to be centralized, not spread out all over the place.
    >
    Use a URLClassloader to load the URL that isobtained
    for each file with file.toURI().toURL()(file.toURL()
    is depricated in 1.6)Wrong, the URL you give it must be that of the
    directory, not the class file.No, I did this quite recently, you can give it a specific class file to load.
    >
    Load all of the classes in this directory, thatway
    any anonymous classes are loaded as well.Anonymous classes automatically loaded when the real
    one isIt can't load it if it doesn't know where the code is. Since you haven't used a URL classloader to load once class file at a time, you would never encounter this. But if you loaded a class file that had an anonymous classfile it needed, would it know where to look for it?
    >
    From this point you should be able to just get a
    class with Class.forName(name)No. Class.forName uses the classloader of the class
    it's called in, which will be the system classloader.
    It won't find classes loaded by a URLClassLoader.got me there.

  • How to load a class in lib/file.jar

    Hi,
    I use jboss 4.0.2. and i have a jar-file from a third party in my server/default/lib that calls Thread.currentThread().getContextClassLoader().loadClass("foo"); My problem is that foo.class is never found and i dont know where i have to place this class. I would like to have a seperate folder for my classes, but i dont know how i should configure the classloader to find my classes. i dont want to package them in a jar.
    Thanks a lot!

    i tried this but the class was not found
    my simple question is:
    if a class in a jar that is placed in my jboss/server/default/lib-directory tries to load a class dynamic, where is it(classloader) looking? please tell me...
    thanks

  • How i load java class through javascript

    Hi,
    i want to load java class file at client side through the java script. Class file wich already at client side(client machine)
    tell me is it possible....
    thanks
    plzz mail
    [email protected]

    From your post it is not very clear what you want to do.
    1. Even if it was possible to load client classes using javascript, how on earth are you going to execute them ??? JavaScript and java are entirely different cups of tea.
    2. If it was an applet, then probably you can access some classes from the client machine. Definely the default packages. However, I don't know whether you can access other classes. That might lead to a security issue. Please check with a java securities expart.
    3. Loading a class from the client machine is DEFINITELY A BAD PROGRAMMING PRACTICE Use the codebase property on your applet tag to load the classes from the server.

  • How to load a Class Dynamically?

    hi,
    I have the following problem.I am trying to load a class dynamically.For this I am using ClassLoader and its Loadclass method.My code is like this,
    File file = filechooser.getSelectedFile();
    ClassLoader Cload = this.getClass().getClassLoader();
    String tempClsname= file.getName();
    Class cd =Cload.loadClass(tempClsname);
    Object ob =(Object)cd.newInstance();
    showMethods(ob);
    In showMethods what i am doing is getting the public methods of the dynamically loaded class,
    void showMethods(Object o){
    Class c = o.getClass();
    System.out.println(c.getName());
    vecList = new Vector();
    Method theMethods[] = c.getDeclaredMethods();
    for (int i = 0; i < theMethods.length; i++) {
    if(theMethods.getModifiers()==java.lang.reflect.Modifier.PUBLIC)
    String methodString = theMethods.getName();
    System.out.println(methodString);
    vecList.addElement(methodString);
    allmthdlst.setListData(vecList);
    Now whenever i work with this i m getting a runtime error of CLASS NOT FOUND Exception..I know its because of Classpath..But i don't know how to resolve it??pls help me in this regard...
    Also previously this code was working with java files in the directory in which this java file was present..How to make it work for java file in some other directory..pls help me in this regard...
    Thanks in advance..

    You sure didn't need to post this twice.
    http://forum.java.sun.com/thread.jsp?thread=522234&forum=31&message=2498659
    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read and prevents accidental markup from array indices like [i].
    You resolve this problem by ensuring the class is in the classpath and you refer to it by its full name.
    &#167;

  • My macbook pro osx 10.9.4 has adware and applications that I cannot delete. How do I clean this problem?

    I would like to learn how to clean out the applications I'm not using and the adware that I have accrued on this laptop. It's running slowly and gets ads. It is just under 3 years old. I checked and some how the firewall has been down on it. Any troubleshooting?

    RobertRagan wrote:
    I'm running Clamx right now and it's about a quarter done. It's found a Geneio adware but I'm going to let it finish. Is it possible that Adware medic missed parts?
    Most likely, ClamXav has found the installer or something like that. AdwareMedic only removes installed items, not things like the installer.
    I'm no longer seeing ads but my Memory is still being taken up quite a bit. Not sure if related but when I go to the Macintosh HD window and verify disk it still will not let me repair the disk.
    None of that is adware-related.
    I'm unclear on what you mean when you say your "memory is still being taken up" - are you referring to RAM (memory) or hard drive space (storage)? What specific behavior are you seeing?
    As for not being able to repair the disk, you can't do that unless you have started up from a different system, like the recovery partition. See:
    http://pondini.org/OSX/DU6.html
    If you have done that and are getting an error message when you try to repair the disk, what is the exact wording of the message?

  • Hello, i just downloaded my digital copy of UP--i uploaded it to DropBox to then, Download to my Ipad--there is no application that supports the protected M4V--how can i get the movie on my Ipad as it said i could have it on any Apple Device, Thanks, Davi

    need some help on my ipad transferring digital copy from dropbox or from my pc.  cant do it from dropbox because the file is protected.
    my digital copy say i can put it on any Apple device.
    can someone advise me?
    David          thanks!
    <Email Edited by Host>

    you can import that file in itunes, verify it plays, then attempt to sync to ipad with itunes. I have had limited success, cause some of the versions will not transfer.

  • Can we handle multiple fields delimiter in sql*loader

    Hi,
    Users wants to load the data from each of their individual system. But problem is when they save the csv file, due to their sytem setup some files gettng saved with pipe (|) seperated and on some system it is saved with comma (,) sepearted fields.
    Can we handle both these field seperator in control file?
    Please suggest
    Thanks,
    Rahul

    Rahul,
    I recommned you should use "|" as "," can be embedded in a text string. I guess you can pass a directive to use to deliver "|" delimited file :). If you want to handle both then you might have to write a shell script or bat to pass delimiter as an argument which will edit and replace your control file.
    Regards

Maybe you are looking for

  • Creating Selection screen in Query Designer

    Hi all, I am New to BI . I need to know how do I put up a selection screen in the Bex Analyser? Regards, Shashank

  • Basic doubt in CTE

    Hi all,    Learning CTE in deep, I encountered the sentence "Enable grouping by a column that is derived from a scalar subselect, or a function that is either not deterministic or has external access" What is the exact issue of CTE here,How CTE appli

  • Location of physical data

    Hi, Is there anyway we can choose where Tangosol stores its data - i.e either RAM, files on disk, or database? Rohit

  • Migration of IDs from 4.5 to 11i ...

    Hi, is there someone who is using OFSA 11i (Performance Analyzer and Transfer Pricing) and can tell me if there are any efforts to take for upgrading from 4.5 to 11i? I mean do I need to migrate all or some of the existing IDs to the new version or d

  • Prcing schema problem

    Hi, In production system: Two condition types (e.g. JEXC- Excise duty, JCST-central sales tax) are assigned wrongly to pricing procedure instead of TAXINN procedure when our company was implemented for client. In Test/quality system: Now JEXC, JCST c