This topic describes how to use a Cassandra client driver for Java to connect to and use the wide table engine over Cassandra Query Language (CQL).
Prerequisites
Java Development Kit (JDK) 1.8 or later is installed.
A Cassandra client driver for Java is installed over CQL.
The IP address of your client is added to an allowlist of the Lindorm instance. For more information, see Configure whitelists.
The CQL endpoint that is used to connect to LindormTable is obtained. For more information, see View endpoints.

Procedure
Set connection parameters.
String[] contactPoints = new String[]{ "<host>" }; Cluster cluster = Cluster.builder() .addContactPoints(contactPoints) .withAuthProvider(new PlainTextAuthProvider(username, password)) .build(); cluster.init(); Session session = cluster.connect();Note<host>: specifies the CQL endpoint of LindormTable, such asld-bp17j28j2y7pm****-proxy-lindorm.lindorm.rds.aliyuncs.com. You can obtain the CQL endpoint in the Lindorm console.username: specifies the username of the Lindorm instance. The default value is root.password: specifies the password that corresponds to the username of the Lindorm instance. If you forget the password, you can use the Lindorm Insight system of LindormTable to reset the password. For more information, see Change the password of a user.
Use the API operations of the Cassandra client driver for Java to access a Lindorm wide table over CQL. The following code block provides an example on how to access a Lindorm wide table:
DDL operations
// Create a keyspace. Configure a replication strategy and a replication factor for the keyspace. session.execute( "CREATE KEYSPACE IF NOT EXISTS testKeyspace WITH replication " + "= {'class':'SimpleStrategy', 'replication_factor':1};"); // Create a table and specify a primary key, a cluster key, and a regular key for the table. session.execute( "CREATE TABLE IF NOT EXISTS testKeyspace.testTable (" + "id int PRIMARY KEY," + "name text," + "age int," + "address text" + ");"); // Clear the table. session.execute("TRUNCATE TABLE testKeyspace.testTable;"); // Delete the table. session.execute("DROP TABLE testKeyspace.testTable ");DML operations
// Execute the INSERT statement. session.execute( "INSERT INTO testKeyspace.testTable (id, name, age, address) " + "VALUES (" + "1," + "'testname'," + "11," + "'hangzhou');"); // Execute the SELECT statement. If you want to query all columns in a table, use SELECT *. You can also specify the columns that you want to query. ResultSet res = session.execute( "SELECT * FROM testKeyspace.testTable ;"); // If you want to query data of each column, execute the following statements: for (Row row : res) { int id = row.getInt("id"); String name = row.getString("name"); int age = row.getInt("age"); String address = row.getString("address"); } // Close the session. session.close(); // Shut down the cluster. cluster.close();