Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » How to add a jdbc driver that uses native code?
How to add a jdbc driver that uses native code? [message #22265] Sun, 22 October 2006 19:23 Go to next message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
Hi,

I'd like to add a jdbc driver for SQLite (http://www.sqlite.org)
http://www.zentus.com/sqlitejdbc

The problem is that the driver consists of a jar library
and a native JNI binding library.

I thought I could do it using the Generic JDBC driver.
But I could not figure out how to specify the library
path for the native library.

I tried to drop the native library next to the
eclipse executable. It finds the native library,
but the generic jdbc connection seems to use
multiple class loaders to load the library
multiple times. This causes problems with
the loaded library. I get the following error:

Error creating JDBC Connection connection to sqlite.
(Error: Native Library C:\eclipse\sqlitejdbc.dll already loaded in another classloader)

What's the best solution for this problem?

Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: How to add a jdbc driver that uses native code? [message #22429 is a reply to message #22265] Fri, 27 October 2006 19:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.graham.sybase.com

Michael Scharf wrote:

> Hi,

> I'd like to add a jdbc driver for SQLite (http://www.sqlite.org)
> http://www.zentus.com/sqlitejdbc

> The problem is that the driver consists of a jar library
> and a native JNI binding library.

> I thought I could do it using the Generic JDBC driver.
> But I could not figure out how to specify the library
> path for the native library.

> I tried to drop the native library next to the
> eclipse executable. It finds the native library,
> but the generic jdbc connection seems to use
> multiple class loaders to load the library
> multiple times. This causes problems with
> the loaded library. I get the following error:

> Error creating JDBC Connection connection to sqlite.
> (Error: Native Library C:eclipsesqlitejdbc.dll already loaded in another
classloader)

> What's the best solution for this problem?

> Michael

Hi Michael,

We've seen this sort of problem before, but I don't know if we've covered
this specific case. I'll forward this post to the committers working in
that area to get their feedback.

Regards,
John Graham
Eclipse Data Tools Platform PMC Chair
Re: How to add a jdbc driver that uses native code? [message #22470 is a reply to message #22429] Fri, 27 October 2006 20:46 Go to previous messageGo to next message
Rob Cernich is currently offline Rob CernichFriend
Messages: 56
Registered: July 2009
Member
I've created a defect for this. However, it should be noted that there
may not be a comprehensive solution that can be applied at the framework
level.

Each driver definition is capable of managing a shared classloader,
however the current JDBC connection factories do not use the shared
classloader. This means each connection created by the factory is
associated with its own classloader. The problem can be minimized by
using the shared classloader, however this will not prevent the problem
from occurring if more than one driver definition references the same
native library.

The code contributing the connection profile/factory can use its own
method for setting up the referenced libraries. For example, a the plugin
containing the connection factory may specify the driver libraries as part
of the plugin's runtime. The connection factory could then use its plugin
classloader when creating the connection. If support for multiple driver
versions is required, this approach should be satisfactory so long as the
individual plugins reference the plugin with ties to the native library.

Probably a bit more than you wanted to know. Here's the BZ entry:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=162625

Regards,
Rob
Re: How to add a jdbc driver that uses native code? [message #22514 is a reply to message #22470] Tue, 31 October 2006 11:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gaoxm2001.gmail.com

Hi Rob,

Our project is also blocked by this bug.
when do you think the bug could be fixed?
I see its priority is only 3.....

Thanks a lot,
Xiaoming


"Rob Cernich" <rcernich@sybase.com>
??????:ead088e79fa19f19b917dc9c6e559fae$1@www.eclipse.org...
> I've created a defect for this. However, it should be noted that there
> may not be a comprehensive solution that can be applied at the framework
> level.
>
> Each driver definition is capable of managing a shared classloader,
> however the current JDBC connection factories do not use the shared
> classloader. This means each connection created by the factory is
> associated with its own classloader. The problem can be minimized by
> using the shared classloader, however this will not prevent the problem
> from occurring if more than one driver definition references the same
> native library.
>
> The code contributing the connection profile/factory can use its own
> method for setting up the referenced libraries. For example, a the plugin
> containing the connection factory may specify the driver libraries as part
> of the plugin's runtime. The connection factory could then use its plugin
> classloader when creating the connection. If support for multiple driver
> versions is required, this approach should be satisfactory so long as the
> individual plugins reference the plugin with ties to the native library.
>
> Probably a bit more than you wanted to know. Here's the BZ entry:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=162625
>
> Regards,
> Rob
>
>
Re: How to add a jdbc driver that uses native code? [message #22871 is a reply to message #22514] Wed, 08 November 2006 14:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brianf.sybase.com

We just delivered fixes for this issue last night. Should hopefully appear
in today's build. The issue still remains if a driver has been loaded into a
classloader. At this time, there isn't a way to "unload" it if the jars or
classname for a given driver instance have changed. You can change the jars
and class name and try to reconnect to any profile using that driver. If you
get an error saying the class was already loaded in a classloader, you will
have to close and restart Eclipse before the change will be picked up.

But can you give it a shot with this fix?

Thanks
--Brian Fitzpatrick
Sybase, Inc./DTP Connectivity

"xiaoming gao" <gaoxm2001@gmail.com> wrote in message
news:ei7dqi$sfi$1@utils.eclipse.org...
> Hi Rob,
>
> Our project is also blocked by this bug.
> when do you think the bug could be fixed?
> I see its priority is only 3.....
>
> Thanks a lot,
> Xiaoming
>
>
> "Rob Cernich" <rcernich@sybase.com>
> ??????:ead088e79fa19f19b917dc9c6e559fae$1@www.eclipse.org...
>> I've created a defect for this. However, it should be noted that there
>> may not be a comprehensive solution that can be applied at the framework
>> level.
>>
>> Each driver definition is capable of managing a shared classloader,
>> however the current JDBC connection factories do not use the shared
>> classloader. This means each connection created by the factory is
>> associated with its own classloader. The problem can be minimized by
>> using the shared classloader, however this will not prevent the problem
>> from occurring if more than one driver definition references the same
>> native library.
>>
>> The code contributing the connection profile/factory can use its own
>> method for setting up the referenced libraries. For example, a the
>> plugin containing the connection factory may specify the driver libraries
>> as part of the plugin's runtime. The connection factory could then use
>> its plugin classloader when creating the connection. If support for
>> multiple driver versions is required, this approach should be
>> satisfactory so long as the individual plugins reference the plugin with
>> ties to the native library.
>>
>> Probably a bit more than you wanted to know. Here's the BZ entry:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=162625
>>
>> Regards,
>> Rob
>>
>>
>
>
Re: How to add a jdbc driver that uses native code? [message #23388 is a reply to message #22871] Wed, 22 November 2006 09:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gaoxm2001.gmail.com

Hi Brian,

Thanks for the fixing.
I downloaded the Night build on 111606 and verified the old class loader
problem is really fixed.
But I hit another error as shown below when connect to our database.
Could you please give me any advice about the problem investigation if
possible? Thanks a lot.

!MESSAGE Error creating SQL Model Connection connection to
connection_profile. (Error: null)
!STACK 0
java.lang.NullPointerException
at
org.eclipse.datatools.connectivity.sqm.internal.core.util.Da tabaseProviderHelper.getCatalogDatabase(DatabaseProviderHelp er.java:37)
at
org.eclipse.datatools.connectivity.sqm.internal.core.util.Da tabaseProviderHelper.setDatabase(DatabaseProviderHelper.java :46)
at
org.eclipse.datatools.connectivity.sqm.internal.core.connect ion.ConnectionInfoImpl. <init>(ConnectionInfoImpl.java:626)
at
org.eclipse.datatools.connectivity.sqm.internal.core.connect ion.ConnectionFactory.createConnection(ConnectionFactory.jav a:36)
at
org.eclipse.datatools.connectivity.sqm.core.SQMConnectionFac tory.createConnection(SQMConnectionFactory.java:45)
at
org.eclipse.datatools.connectivity.internal.ConnectionFactor yAdapterProvider.createConnection(ConnectionFactoryAdapterPr ovider.java:79)
at
org.eclipse.datatools.connectivity.internal.CreateConnection Job.run(CreateConnectionJob.java:55)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
!SUBENTRY 1 org.eclipse.core.runtime 2006-11-22 17:20:31.312
!MESSAGE OK

Best Regards,
Xiaoming


"Brian Fitzpatrick" <brianf@sybase.com> д
Re: How to add a jdbc driver that uses native code? [message #23689 is a reply to message #23388] Thu, 30 November 2006 20:10 Go to previous messageGo to next message
Rob Cernich is currently offline Rob CernichFriend
Messages: 56
Registered: July 2009
Member
Hey Xiaoming,

My guess is that the DB vendor and version number are not set in either
your driver definition or connection profile instance. These values
correspond with the product and version attributes in a databaseDefinition
extension. If they are not specified, the dbdefinition file cannot be
resolved and an exception will be thrown.

The ConnectionInfo class (which wraps the SQL model) will look for the
following properties in a connection profile:
org.eclipse.datatools.connectivity.db.vendor
org.eclipse.datatools.connectivity.db.version

If you are using the generic tooling, these properties will be populated
using similarly named properties in the referenced driver definition.

The constants for these property keys are defined in
org.eclipse.datatools.connectivity.db.generic.IDBDriverDefin itionConstants
in the org.eclipse.datatools.connectivity.db.generic plugin.

Hope that helps.
Rob
Re: How to add a jdbc driver that uses native code? [message #29427 is a reply to message #22265] Fri, 13 April 2007 05:19 Go to previous message
Sabeesh C.S. is currently offline Sabeesh C.S.Friend
Messages: 21
Registered: July 2009
Junior Member
Hi,

I think your problum is that, your programe canot connect to SQLite.
First you create a database in sqlite and copy it into your programe's
home directory. In my case it is, if the programe name ConnectSQLite,
"D:\WorkSpace\ConnectSQLite\ " . Download the driver
http://www.zentus.com/sqlitejdbc/dist/sqlitejdbc-v033-nested .tgz ( pure
java driver ). It is a jar file. Copy this file also into your
programe's home directory. I am sure that, it is working.

If you create a plugin, then, extract this jar file and copy the org
directory into your programe's src directory and bin directory. Then it
is working
Try this, if any problum, contact me at sabeesh.cs@ditro.com /
sabeeshcs@gmail.com

Sabeesh C.S
Re: How to add a jdbc driver that uses native code? [message #582748 is a reply to message #22265] Fri, 27 October 2006 19:35 Go to previous message
John Graham is currently offline John GrahamFriend
Messages: 183
Registered: July 2009
Senior Member
Michael Scharf wrote:

> Hi,

> I'd like to add a jdbc driver for SQLite (http://www.sqlite.org)
> http://www.zentus.com/sqlitejdbc

> The problem is that the driver consists of a jar library
> and a native JNI binding library.

> I thought I could do it using the Generic JDBC driver.
> But I could not figure out how to specify the library
> path for the native library.

> I tried to drop the native library next to the
> eclipse executable. It finds the native library,
> but the generic jdbc connection seems to use
> multiple class loaders to load the library
> multiple times. This causes problems with
> the loaded library. I get the following error:

> Error creating JDBC Connection connection to sqlite.
> (Error: Native Library C:eclipsesqlitejdbc.dll already loaded in another
classloader)

> What's the best solution for this problem?

> Michael

Hi Michael,

We've seen this sort of problem before, but I don't know if we've covered
this specific case. I'll forward this post to the committers working in
that area to get their feedback.

Regards,
John Graham
Eclipse Data Tools Platform PMC Chair
Re: How to add a jdbc driver that uses native code? [message #582767 is a reply to message #22429] Fri, 27 October 2006 20:46 Go to previous message
Rob Cernich is currently offline Rob CernichFriend
Messages: 56
Registered: July 2009
Member
I've created a defect for this. However, it should be noted that there
may not be a comprehensive solution that can be applied at the framework
level.

Each driver definition is capable of managing a shared classloader,
however the current JDBC connection factories do not use the shared
classloader. This means each connection created by the factory is
associated with its own classloader. The problem can be minimized by
using the shared classloader, however this will not prevent the problem
from occurring if more than one driver definition references the same
native library.

The code contributing the connection profile/factory can use its own
method for setting up the referenced libraries. For example, a the plugin
containing the connection factory may specify the driver libraries as part
of the plugin's runtime. The connection factory could then use its plugin
classloader when creating the connection. If support for multiple driver
versions is required, this approach should be satisfactory so long as the
individual plugins reference the plugin with ties to the native library.

Probably a bit more than you wanted to know. Here's the BZ entry:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=162625

Regards,
Rob
Re: How to add a jdbc driver that uses native code? [message #582786 is a reply to message #22470] Tue, 31 October 2006 11:55 Go to previous message
Eclipse UserFriend
Originally posted by: gaoxm2001.gmail.com

Hi Rob,

Our project is also blocked by this bug.
when do you think the bug could be fixed?
I see its priority is only 3.....

Thanks a lot,
Xiaoming


"Rob Cernich" <rcernich@sybase.com>
??????:ead088e79fa19f19b917dc9c6e559fae$1@www.eclipse.org...
> I've created a defect for this. However, it should be noted that there
> may not be a comprehensive solution that can be applied at the framework
> level.
>
> Each driver definition is capable of managing a shared classloader,
> however the current JDBC connection factories do not use the shared
> classloader. This means each connection created by the factory is
> associated with its own classloader. The problem can be minimized by
> using the shared classloader, however this will not prevent the problem
> from occurring if more than one driver definition references the same
> native library.
>
> The code contributing the connection profile/factory can use its own
> method for setting up the referenced libraries. For example, a the plugin
> containing the connection factory may specify the driver libraries as part
> of the plugin's runtime. The connection factory could then use its plugin
> classloader when creating the connection. If support for multiple driver
> versions is required, this approach should be satisfactory so long as the
> individual plugins reference the plugin with ties to the native library.
>
> Probably a bit more than you wanted to know. Here's the BZ entry:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=162625
>
> Regards,
> Rob
>
>
Re: How to add a jdbc driver that uses native code? [message #582974 is a reply to message #22514] Wed, 08 November 2006 14:07 Go to previous message
Brian Fitzpatrick is currently offline Brian FitzpatrickFriend
Messages: 500
Registered: July 2009
Senior Member
We just delivered fixes for this issue last night. Should hopefully appear
in today's build. The issue still remains if a driver has been loaded into a
classloader. At this time, there isn't a way to "unload" it if the jars or
classname for a given driver instance have changed. You can change the jars
and class name and try to reconnect to any profile using that driver. If you
get an error saying the class was already loaded in a classloader, you will
have to close and restart Eclipse before the change will be picked up.

But can you give it a shot with this fix?

Thanks
--Brian Fitzpatrick
Sybase, Inc./DTP Connectivity

"xiaoming gao" <gaoxm2001@gmail.com> wrote in message
news:ei7dqi$sfi$1@utils.eclipse.org...
> Hi Rob,
>
> Our project is also blocked by this bug.
> when do you think the bug could be fixed?
> I see its priority is only 3.....
>
> Thanks a lot,
> Xiaoming
>
>
> "Rob Cernich" <rcernich@sybase.com>
> ??????:ead088e79fa19f19b917dc9c6e559fae$1@www.eclipse.org...
>> I've created a defect for this. However, it should be noted that there
>> may not be a comprehensive solution that can be applied at the framework
>> level.
>>
>> Each driver definition is capable of managing a shared classloader,
>> however the current JDBC connection factories do not use the shared
>> classloader. This means each connection created by the factory is
>> associated with its own classloader. The problem can be minimized by
>> using the shared classloader, however this will not prevent the problem
>> from occurring if more than one driver definition references the same
>> native library.
>>
>> The code contributing the connection profile/factory can use its own
>> method for setting up the referenced libraries. For example, a the
>> plugin containing the connection factory may specify the driver libraries
>> as part of the plugin's runtime. The connection factory could then use
>> its plugin classloader when creating the connection. If support for
>> multiple driver versions is required, this approach should be
>> satisfactory so long as the individual plugins reference the plugin with
>> ties to the native library.
>>
>> Probably a bit more than you wanted to know. Here's the BZ entry:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=162625
>>
>> Regards,
>> Rob
>>
>>
>
>
Re: How to add a jdbc driver that uses native code? [message #583132 is a reply to message #22871] Wed, 22 November 2006 09:55 Go to previous message
Eclipse UserFriend
Originally posted by: gaoxm2001.gmail.com

Hi Brian,

Thanks for the fixing.
I downloaded the Night build on 111606 and verified the old class loader
problem is really fixed.
But I hit another error as shown below when connect to our database.
Could you please give me any advice about the problem investigation if
possible? Thanks a lot.

!MESSAGE Error creating SQL Model Connection connection to
connection_profile. (Error: null)
!STACK 0
java.lang.NullPointerException
at
org.eclipse.datatools.connectivity.sqm.internal.core.util.Da tabaseProviderHelper.getCatalogDatabase(DatabaseProviderHelp er.java:37)
at
org.eclipse.datatools.connectivity.sqm.internal.core.util.Da tabaseProviderHelper.setDatabase(DatabaseProviderHelper.java :46)
at
org.eclipse.datatools.connectivity.sqm.internal.core.connect ion.ConnectionInfoImpl. <init>(ConnectionInfoImpl.java:626)
at
org.eclipse.datatools.connectivity.sqm.internal.core.connect ion.ConnectionFactory.createConnection(ConnectionFactory.jav a:36)
at
org.eclipse.datatools.connectivity.sqm.core.SQMConnectionFac tory.createConnection(SQMConnectionFactory.java:45)
at
org.eclipse.datatools.connectivity.internal.ConnectionFactor yAdapterProvider.createConnection(ConnectionFactoryAdapterPr ovider.java:79)
at
org.eclipse.datatools.connectivity.internal.CreateConnection Job.run(CreateConnectionJob.java:55)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
!SUBENTRY 1 org.eclipse.core.runtime 2006-11-22 17:20:31.312
!MESSAGE OK

Best Regards,
Xiaoming


"Brian Fitzpatrick" <brianf@sybase.com> д
Re: How to add a jdbc driver that uses native code? [message #583245 is a reply to message #23388] Thu, 30 November 2006 20:10 Go to previous message
Rob Cernich is currently offline Rob CernichFriend
Messages: 56
Registered: July 2009
Member
Hey Xiaoming,

My guess is that the DB vendor and version number are not set in either
your driver definition or connection profile instance. These values
correspond with the product and version attributes in a databaseDefinition
extension. If they are not specified, the dbdefinition file cannot be
resolved and an exception will be thrown.

The ConnectionInfo class (which wraps the SQL model) will look for the
following properties in a connection profile:
org.eclipse.datatools.connectivity.db.vendor
org.eclipse.datatools.connectivity.db.version

If you are using the generic tooling, these properties will be populated
using similarly named properties in the referenced driver definition.

The constants for these property keys are defined in
org.eclipse.datatools.connectivity.db.generic.IDBDriverDefin itionConstants
in the org.eclipse.datatools.connectivity.db.generic plugin.

Hope that helps.
Rob
Re: How to add a jdbc driver that uses native code? [message #585245 is a reply to message #22265] Fri, 13 April 2007 05:19 Go to previous message
Sabeesh C.S. is currently offline Sabeesh C.S.Friend
Messages: 21
Registered: July 2009
Junior Member
Hi,

I think your problum is that, your programe canot connect to SQLite.
First you create a database in sqlite and copy it into your programe's
home directory. In my case it is, if the programe name ConnectSQLite,
"D:\WorkSpace\ConnectSQLite\ " . Download the driver
http://www.zentus.com/sqlitejdbc/dist/sqlitejdbc-v033-nested .tgz ( pure
java driver ). It is a jar file. Copy this file also into your
programe's home directory. I am sure that, it is working.

If you create a plugin, then, extract this jar file and copy the org
directory into your programe's src directory and bin directory. Then it
is working
Try this, if any problum, contact me at sabeesh.cs@ditro.com /
sabeeshcs@gmail.com

Sabeesh C.S
Previous Topic:relative location of driver JAR file
Next Topic:Create a set of plug-in
Goto Forum:
  


Current Time: Tue Jan 14 01:50:51 GMT 2025

Powered by FUDForum. Page generated in 0.05429 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top