ing-bank/cassandra-jdbc-wrapper

Connecting Cassandra to JNDI in WildFly: A Guide for Integration with cassandra-jdbc-wrapper-4.11.0.jar

Arjunguptha98 opened this issue · 3 comments

Hi team,
I've developed this project and obtained the cassandra-jdbc-wrapper-4.11.0.jar. With this JAR, I've successfully executed a Java JDBC program. Currently, I'm attempting to establish a connection between Cassandra and JNDI (using WildFly). Could you provide guidance on achieving this use case if it's possible?

Hello @Arjunguptha98,

I´m not sure to understand your question.
If you want to configure a JDBC datasource identified by a JNDI name in WildFly, there is nothing specific to do for this driver and you can configure the datasource as any JDBC datasource in Wildfly as explained in the reference documentation.

And you can refer to this page for driver and connection URL settings.

Hi @maximevw
Thank you for your reply. I've obtained the JDBC URL for Cassandra. However, I'm uncertain about how to configure the Cassandra driver in standalone.xml and module.xml.

Hello @Arjunguptha98

First of all, I will convert this to a discussion as your question is not an issue related to the JDBC driver. :)

I have no expertise with Wildfly, but based on the following sources (here and there), I think you should do something like this:

  1. Download the driver JAR.
  2. Put the JAR in the folder {WildFlyDirectory}/modules/system/layers/base/com/ing/data and create a module.xml file in the same folder:
<module xmlns="urn:jboss:module:1.9" name="com.ing.data">
  <resources>
    <resource-root path=" cassandra-jdbc-wrapper-4.11.0-bundle.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>
  1. In the standalone.xml file, locate the <subsystem>/<datasources> part and include the following datasource :
<datasource jndi-name="java:jboss/datasources/cassandraDS" pool-name="cassandraDS" enabled="true">
  <connection-url>{JDBC URL}</connection-url>
  <driver>cassandra</driver>
  <security>
    <user-name>{username}</user-name>
    <password>{password}</password>
  </security>
</datasource>
  1. Then, also in standalone.xml, locate the tag <drivers> and put this inside:
<driver name="cassandra" module="com.ing.data">
  <driver-class>com.ing.data.cassandra.jdbc.CassandraDriver</driver-class>
</driver>
  1. Reboot the Wildfly server.

There is no guarantee it works exactly like this, I just deduced that from various documentation found on the Internet and I never tested this.

I really encourage you to consult the WildFly Admin guide for further details on JDBC datasource configuration.