Apache Cassandra and BIRT [message #806127] |
Fri, 24 February 2012 10:19  |
Eclipse User |
|
|
|
Cassandra is a NoSQL database used by Twitter and many other high data applications. Even though Cassandra is NoSQL, there is a SQL alike language (CQL) and even a JDBC wrapper for CQL (http://code.google.com/a/apache-extras.org/p/cassandra-jdbc/). Using these two techniques I'm able to access Cassandra from Java as if it were a RDBMS:
public class CassandraJdbcTrial
{
static public void main (String[] args) throws ClassNotFoundException, SQLException
{
Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
Connection con = DriverManager.getConnection("jdbc:cassandra://localhost:9160/M2A");
String query = "SELECT * from InstanceLicense";
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery(query);
while (result.next())
{
for (int i = 1; i <= result.getMetaData().getColumnCount(); i++)
{
System.out.println( result.getMetaData().getColumnName(i) + "=" + result.getString(i) );
}
System.out.println("-----");
}
}
}
This results in the output below:
KEY=L0000001_n1234_20120221_32
javaxdiff=java.nio.HeapByteBuffer[pos=114832 lim=115193 cap=116325]
-----
KEY=L0000001_n1234_20120217_1599670502
javaxdiff=java.nio.HeapByteBuffer[pos=115341 lim=115703 cap=116325]
-----
....
If I set this JDBC driver up in BIRT, the "test connection" on the Data Source works fine. I can also create a Data Set, but there are no output columns. Also if I just do a "select KEY from InstanceLicense". What is the JDBC driver not doing right?
Tom
|
|
|
|
|
|
Re: Apache Cassandra and BIRT [message #809420 is a reply to message #808921] |
Tue, 28 February 2012 16:24  |
Eclipse User |
|
|
|
Did you get this to work? If so I would love to see a blog post on it.
Jason
On 2/28/2012 4:39 AM, tbee wrote:
> I've patched Cassandra's JDBC driver to do a read ahead when getMetadata
> is done before the first row of data is read. The problem with Cassandra
> is that it does not have a database schema, only collections of
> key-value pairs, and therefore each row may have different contents.
>
> In real life use this turns out not to be such a big issue, since one
> usually writes the same values in each row, but it does require a row to
> be fetched in order to determine what columns are available.
>
> Patched. Thanks!
>
> Tom
|
|
|
Powered by
FUDForum. Page generated in 0.03077 seconds