DbSchema for Cassandra Database

DbSchema is a powerful database management and design tool for Cassandra. It offers features such as visual schema design, team collaboration with GIT, schema deployment and HTML schema documentation.

How to Connect to Cassandra Database

  1. Access the Connection Dialog

    Choose "Connect to the database" or "New Model Connected to the Database" will let you select your database and open the Connection Dialog.

    DbSchema automatically downloads the JDBC driver to connect to your database.

  2. Configure the Connection
  3. In the Connection Dialog window, select the JDBC URL you want to connect with. If your database is running in the cloud, choose Edit Manually and insert the JDBC URL from the cloud console.

    Enter the host name, the authentication details, select your database as described in the Connection Dialog page.

  4. Troubleshoot Firewall Issues
  5. If you encounter connection issues, it may be due to firewall settings. Read how to enable Firewall Connections.
Remember to enable Windows Firewalls Firewalls & anti-viruses may block database connections.

How to Configure the Cassandra JDBC URL

DbSchema connects to Cassandra using its own JDBC driver which calls the native Cassandra driver. The DbSchema driver is open source and can be found at /jdbc-driver/Cassandra.html.

The default DbSchema connection dialog shows an option to connect only to a single host. To connect to multiple hosts use the 'JDBC URL' tab and edit a string like here:

    jdbc:cassandra://host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[keyspace];[dataCenter][&options]]
    

Find the DataCenter using 'nodetool status' or 'nodetool -h ::FFFF:127.0.0.1 status'.

This will be translate an URL like jdbc:cassandra://192.168.0.1:9042/mykeyspace into:

Cluster cluster = Cluster.builder().addContactPoint("192.168.0.1").withPort(9042).build();
Session session = cluster.connect("mykeyspace");

How to configure the Cassandra JDBC URL and connect to the database

Connect using SSL

Edit the DbSchema.vmoptions file (in the DbSchema installation folder or ./DbSchema.app/Contents/vmoptions.txt on Mac OS) and add this parameters:
-Djavax.net.ssl.trustStore=/path/to/client.truststore
-Djavax.net.ssl.trustStorePassword=password123
# If you're using client authentication:
-Djavax.net.ssl.keyStore=/path/to/client.keystore
-Djavax.net.ssl.keyStorePassword=password123

How to Enable Remote Connections for Cassandra on Windows

To enable remote connections you will have to edit the cassandra.yaml file from C:\Program Files\DataStax Community\apache-cassandra\conf

How to edit Cassandra configuration file and allow remote connections
set the
  • start_rpc: true
  • rpc_address: your_ip
  • cdc_raw_directory: "C:/Program Files/DataStax-DDC/data/cdc_raw"
The 'cdc_raw_directory' does not exist in the default configuration file. Cassandra server 3.9 didn't start without adding it. Look in DataStax-DCC/logs for errors.
Setup Cassandra rpc_address
Go to -> Control Panel\System and Security\Administrative Tools -> Services -> Restart service. DataStax DDC Server 3.9.0 .
How to restart the DataStax service on Windows
Cassandra databases talk to each other using a different protocol on a different port. These two can not be the same and gives us some extra configuration. Cassandra Default ports:
- 9042 Cassandra client port.
- 9160 Cassandra client port (Thrift).

How to Run Cassandra using Docker Containers

Install Cassandra as described in this tutorial. This is the simplest method, and ensures all libraries are included.
CREATE KEYSPACE sample
WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy',
'datacenter1' : 3 } AND DURABLE_WRITES = false;

CREATE TABLE sample.table1 ( id int primary key, name text);

####################

CREATE TYPE sample.flagtype (data map<text,text>,working text);

CREATE TABLE sample.table1a (abc text,
                   hello text,
                   flag frozen<flagtype>,
                   PRIMARY KEY (abc));

INSERT INTO sample.table1a JSON '{"abc":"abc", "hello":"world", "flag":{"data":{"hi":"cassandra"}, "working":"no"}}';