ClassLoader and JNI issues

From: Steve Menard (steve.menard_at_videotron.ca)
Date: 06/24/04


Date: Thu, 24 Jun 2004 13:07:03 -0400

I am having problems calling JDBC code from C/C++ via JNI.

I am embedding the JVM, and need access to any JDCB driver.

My problem is the following :

I can get the driver registered no problem, but when it comes time to
try and connect, the DriverManager "skips" over it because the driver's
ClassLoader is not the same as the caller's ClassLoader.

Now, I am calling this from C/C++ code, so there is no caller class, and
so no caller classloader.

I can make it work by bypassing th DriverManager completely, and asking
the driver to connect itself. That's fine as a stopgap solution, but I
would really like to fix this. The same problem occurs when I call
Class.forName(String), as this method looks at the caller's class and
classloader.

Is there a way to set or simulate a current class and/or classloader?

thanks in advance,

Steve



Relevant Pages

  • ClassLoader and JNI issues
    ... I am having problems calling JDBC code from C/C++ via JNI. ... and need access to any JDCB driver. ... ClassLoader is not the same as the caller's ClassLoader. ...
    (comp.lang.java.programmer)
  • Re: Wie funktioniert der DriverManager
    ... Wie kommt dieser an die Driver die man mit ... > Wir haben nun einen DriverManager (geladen vom ClassLoader ... > ClassLoader werden dann alle registrierten ...
    (de.comp.lang.java)
  • Re: Wie funktioniert der DriverManager
    ... Wie kommt dieser an die Driver die man mit Class.forNamegeladen hat. ... Nehmen wir mal an wir haben einen AppServer mit zwei WepApps. ... Wir haben nun einen DriverManager (geladen vom ClassLoader des AppServers) bei dem sich zwei Klassen registriert haben, ... Mit diesem ClassLoader werden dann alle registrierten Driver-Klassen versucht nach ihrem Namen zu laden. ...
    (de.comp.lang.java)
  • Re: obtaining data during data calls?
    ... Yes, it's possible, but not from managed code. ... You'd have to use an NDIS ... intermediate driver, which can only be written in C/C++ with eMbedded Visual ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Accessing peripherals from a managed application
    ... How would a C/C++ program talk to the driver? ... you'd P/Invoke to those API calls from managed code, ... Call on the imported functions to access the hardware. ...
    (microsoft.public.windowsce.app.development)