View RSS Feed

Cassandra

Making Cassandra Database Connection

Rate this Entry
by , 02-23-2012 at 06:06 PM (2382 Views)
First thing to do is to create connection to database. For this purpose, on port 9160 open up a connection that would be a default port of Cassandra. Hand over it to the client of Cassandra and he will be taking care to communication to the server:
Java Code: This is the code to explain Cassandra Database Connection
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

import org.apache.cassandra.thrift.Cassandra;

...

TTransport transport = new TSocket("localhost", 9160);
TProtocol protocol = new TBinaryProtocol(transport);
Cassandra.Client client = new Cassandra.Client(protocol);
transport.open();

Submit "Making Cassandra Database Connection" to Facebook Submit "Making Cassandra Database Connection" to Digg Submit "Making Cassandra Database Connection" to del.icio.us Submit "Making Cassandra Database Connection" to StumbleUpon Submit "Making Cassandra Database Connection" to Google

Comments