You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by jie yan <ya...@gmail.com> on 2011/05/23 18:15:22 UTC

How to find JDBC Driver class in a bundle?

With the help of some engineers in Karaf forum, I've wrapped an Oracle
driver bundle.

But I can't find the suitable way to create a JDBC driver in my Oracle
client bundle.

Attempt 1:
1) <Import-Package>oracle.jdbc</Import-Package>
2) Class.forName("oracle.jdbc.OracleDriver");
Failed.

Attempt 2:
1) <Import-Package>oracle.jdbc</Import-Package>
2) static{
 DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
 }
Failed.

How could I do?

Regards,
drhades

Re: How to find JDBC Driver class in a bundle?

Posted by Justin Edelson <ju...@justinedelson.com>.
You should never use Class.forName(). See
http://blog.bjhargrave.com/2007/09/classforname-caches-defined-class-in.html

Justin

On Mon, May 23, 2011 at 12:15 PM, jie yan <ya...@gmail.com> wrote:
> With the help of some engineers in Karaf forum, I've wrapped an Oracle
> driver bundle.
>
> But I can't find the suitable way to create a JDBC driver in my Oracle
> client bundle.
>
> Attempt 1:
> 1) <Import-Package>oracle.jdbc</Import-Package>
> 2) Class.forName("oracle.jdbc.OracleDriver");
> Failed.
>
> Attempt 2:
> 1) <Import-Package>oracle.jdbc</Import-Package>
> 2) static{
>  DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
>  }
> Failed.
>
> How could I do?
>
> Regards,
> drhades
>

Re: How to find JDBC Driver class in a bundle?

Posted by Guillaume Nodet <gn...@gmail.com>.
You should have a look at the OSGi Enterprise specifications that has
a whole chapter targetted at using JDBC inside OSGi.
See http://www.osgi.org/Download/File?url=/download/r4v42/r4.enterprise.pdf

On Mon, May 23, 2011 at 18:15, jie yan <ya...@gmail.com> wrote:
> With the help of some engineers in Karaf forum, I've wrapped an Oracle
> driver bundle.
>
> But I can't find the suitable way to create a JDBC driver in my Oracle
> client bundle.
>
> Attempt 1:
> 1) <Import-Package>oracle.jdbc</Import-Package>
> 2) Class.forName("oracle.jdbc.OracleDriver");
> Failed.
>
> Attempt 2:
> 1) <Import-Package>oracle.jdbc</Import-Package>
> 2) static{
>  DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
>  }
> Failed.
>
> How could I do?
>
> Regards,
> drhades
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com/