Creating a osgi jdbc driver

For work I have to work with different datasource connections. Not only in a JEE environment but also in a OSGI environment. A datasource needs also a jdbc connection. And a jdbc driver jar bundled in osgi format is not always available. I normally try to find a osgi jdbc jar in the servicemix repository but that will work only for OSS drivers.

For a closed source jdbc driver to be converted to a bundle version of the jar you could use a maven plugin. But that is more work then the following:

Fire up a Fusesource or JBoss Fuse instance and have the jdbc driver available on the disk. Inside the fuse console execute the command ‘osgi:install wrap:file:///tmp/ojdbc6.jar’.  When the command finished it will return a number.

Use this number to go to the cache directory with this number (data/cache/bundlexxx/version0.0). Inside the directory you will find the ojdbc6.jar named as bundle.jar. Take the bundle.jar and rename it (back) to ojdbc6-osgi.jar. The -osgi addition is just a naming convention I adopted. Place ojdbc6-osgi.jar in your package manager.