Main Content

close

Close Apache Cassandra database connection

Since R2021a

Description

close(conn) closes the Cassandra® database connection.

example

Examples

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: "127.0.0.1"
    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.

conn.Keyspaces
ans = 6×1 string
    "employeedata"
    "system"
    "system_auth"
    "system_distributed"
    "system_schema"
    "system_traces"

Close the Cassandra database connection.

close(conn)

Input Arguments

collapse all

Apache Cassandra database connection, specified as a connection object.

Version History

Introduced in R2021a