We will use MySQL as an example of how to adapt a plain-vanilla jar file driver to work within the OSGi framework of CRX/CQ.
We assume that you have both the Database Connector-enabled CRX or CQ instance and an instance of MySQL installed on the same machine (MySQL can be downloaded here: http://www.mysql.com/).
The MySQL JDBC driver file is
mysql-connector-java-5.1.12-bin.jar
(it can be downloaded here: http://www.mysql.com/downloads/connector/j)
The first step is to copy the driver file to the shared classpath of your application server. If you are using CQSE (which comes with CRX and CQ) the shared classpath is
crx-quickstart/server/lib/container
If you are using another application server, conult the documentaion for that server to find the shared classpath location.
Simply put the driver jar file there. For example, copying the MySQL JDBC to the shared classpath of CQSE wil result in it being located here:
crx-quickstart/server/lib/container/mysql-connector-java-5.1.12-bin.jar
Next, create a manifest file for converting the standard jar into an OSGi compliant jar, or bundle. Our example manifest file will be called mysql-jdbc.mf with the following content.
sling.bootdelegation.oracle.driver=oracle.jdbc.driver
For 5.3, "boot.delegation" has to be changed to system.packages, e.g.
sling.system.packages.oracle.driver=oracle.jdbc.driver
If the JDBC driver is used by a bundle, which does *not* import the JDBC driver package, then bootdelegation is required.
When using system packages, the driver is added to the exports of the system bundle and can only be used with imports.
If the bundle does import the JDBC driver package, it must be added to the system packages instead of bootdelegation.
Assuming that the bundle using JDBC (the DB pool bundle) does not actually import the JDBC package then bootdelegation is correct.
I have installed the Oracle jdbc driver OSGi bundle using the Felix console and I am able to access the oracle database. But I would like to perform the JCR mapping. Some pointers would help. Thanks.
The best way to go about this is to contact our customer support team. Visit http://www.day.com/day/en/company/contact_us.html to find out the best person to contact for your region.
One time I got connection and even I can get data from database using select query.
but now its not working..I can not able to understand its behavior.
Is is possible can we able to insert data in to database from jsp page using CQ5.4?
Regards,
Satish
You can also refer to:
http://dev.day.com/content/kb/home/cq5/Development/HowToConfigureSling Datasource.html
Hope that helps.
I have cq5.4. I download the latest version of mysqlconnector 'mysql-connector-java-5.1.16-bin.jar', and i am trying to connect to a mysql database. I just add "mysql-connector-java-5.1.16-bin.jar" in the libs folder of the bundle. But when i get to the line of code describe below:
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
It throws me this exception:
com.mysql.jdbc.Driver not found by ...
So i follow the step of "Bundling the Driver" and added the generated jar into the libs folder. And still nothing.
Nevertheless, if i add this jar "mysql-connector-java-3.0.17-ga-bin.jar"(remove the other one) to my libs folder, it works!!
But i want to use the mysql-connector-java-5.1.16-bin.jar. Any ideas how make this work?
I solved my problem. The thing is .. i dont know why this solved the problem.
The problem is with the manifest that comes inside the connector jar of mysql (mysql-connector-java-5.1.16-bin.jar). If i remove this manifest (jar -uMmf MANIFEST.MF mysql-connector-java-5.1.17-bin.jar) and create a manifest like this one:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2-b28 (Sun Microsystems Inc.)
(Blank line)
add the mentioned Manifest to the jar (jar -umf MANIFEST.MF mysql-connector-java-5.1.17-bin.jar); and then add this jar to the libs folder of my bundle. The class is found and i can connect succesfully to the mysql database and retrieve data.
I believe this article is almost 2years old now.Please confirm if this connector is still in beta.
If not please share link to download crx2jdbc-quickstart.jar
Your expedited response will much appreciated
Thanks
Note: Customers with DayCare user accounts need to create a new account for use on day.com.