qwazr / jdbc-cache-driver

A JDBC Cache Driver
7 stars 11 forks source link

Using Cache driver as Datasource #24

Open datsabk opened 6 years ago

datsabk commented 6 years ago

Hello,

Is it possible to configure this cache driver as a JNDI datasource? If yes, how do I do that with IBM Liberty server?

emmanuel-keller commented 6 years ago

jdbc-cache driver is basically a JDBC Driver.

If I refer to this documentation: https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_dep_configuring_ds.html

While copying the jdbc-cache-driver.jar file in C:/DB2/java, it would be possible to do something like that:

<library id="JdbcCacheLib">
    <fileset dir="C:/DB2/java" includes="jdbc-cache-driver.jar"/>
</library>

Then you may use the following template as a datasource definition:

<dataSource id="DefaultDataSource" jndiName="jdbc/jdbcCache">
  <jdbcDriver libraryRef="JdbcCacheLib"/>
  <properties.cache URL="jdbc:cache:mem:my-mem-cache" url="jdbc:oracle:oci:@//localhost:1521/SAMPLEDB"/>                     
</dataSource>

Next, the point is to be able to pass the following properties:

Disclaimer: This is a not tested configuration. It is just here as an example.

Let us know if you can make it work.