Main Content


Close Apache Cassandra database connection

Since R2021a



close(conn) closes the Cassandra® database connection.


collapse all

Create a database connection to an Apache™ Cassandra® database using the Apache Cassandra database C++ interface. To create this connection, you must configure a Cassandra data source. For more information, see the databaseConnectionOptions function. Using a local host address, create the database connection and display the keyspaces in the database.

Create a Cassandra database connection using the configured data source CassandraDataSource and a blank user name and password.

datasource = "CassandraDataSource";
username = "";
password = "";
conn = apacheCassandra(datasource,username,password)
conn = 
  connection with properties:

            Cluster: "Test Cluster"
      HostAddresses: ""
    LocalDataCenter: "datacenter1"
     RequestTimeout: 20
          Keyspaces: [6×1 string]

conn is a connection object that contains these properties:

  • Cassandra cluster name

  • Host address

  • Local data center name

  • Keyspaces

  • Request timeout

Display the keyspaces in the Cassandra database by accessing the Keyspaces property of the connection object.

ans = 6×1 string

Close the Cassandra database connection.


Input Arguments

collapse all

Apache Cassandra database connection, specified as a connection object.

Version History

Introduced in R2021a