karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ward <tim.w...@paremus.com>
Subject Re: java.lang.ClassNotFoundException: org.h2.Driver from bundle ..
Date Sat, 01 Jul 2017 21:52:13 GMT
The correct way to obtain instances of JDBC reources is using a org.osgi.service.jdbc.DataSourceFactory
service. This decouples you from a specific JDBC driver and allows you to pick an appropriate
implementation at runtime. You can inject instances of this service using DS, Blueprint, or
get hold of it in several other ways.

If you really do want to couple to a specific database then you will need to explicitly import
the package that the driver comes from in the bundle that uses it. Note that this is a code
smell, and prevents you from using an alternative, even when testing the bundle.


Sent from my iPhone

> On 1 Jul 2017, at 22:29, smunro <stephen.ross.munro@gmail.com> wrote:
> As addendum,
> I am not using any data sources in karaf using pax-jdbc. The reason being I
> require SQL Server support and opted to do a direct connection via a bundle. 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/java-lang-ClassNotFoundException-org-h2-Driver-from-bundle-tp4050894p4050895.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

View raw message