I am trying to use Apache Cassandra in a project that I am coding using Coldfusion. Since Coldfusion does not have a driver for Apache Cassandra and vice versa, I am trying to use Cassandra Java drivers.
I am pretty new to Java, so please bear with me.
I managed to copy the necessary .jar files to / opt / railo / lib / (I use Railo) and also managed to connect to Cassandra using Coldfusion using the code below. I need help, this is a loop of results returned by Cassandra when executing a query. I have included my very simple code below:
<cfset MyClusterInit = CreateObject("java", "com.datastax.driver.core.Cluster")>
<cfset MyCluster = MyClusterInit.builder().addContactPoint("127.0.0.1").build()>
<cfset MySession = MyCluster.connect("mytest")>
<cfset GetCustomer = MySession.execute("SELECT * FROM customer")>
<cfdump var="#GetCustomer#">
How do I get through the returned results? Cfdump returns the Java method ArrayBackedResultSet $ SinglePage. This is not something that I can iterate through with Coldfusion.
From the “Getting Started With Cassandra and Java” message, I see the code as shown below:
ResultSet results = session.execute("SELECT * FROM users WHERE lastname='Jones'");
for (Row row : results) {
System.out.format("%s %d\n", row.getString("firstname"), row.getInt("age"));
}
How to reproduce above in Coldfusion?
Thanks so much for your time to help.
source
share