时间:2021-07-01 10:21:17 帮助过:23人阅读
<pre name="code" class="java">ResultSet results = session.execute("SELECT * FROM simplex.playlists "); System.out.println(String.format("%-30s\t%-20s\t%-20s\n%s", "title", "album", "artist", "-------------------------------+-----------------------+--------------------")); for (Row row : results) { System.out.println(String.format("%-30s\t%-20s\t%-20s", row.getString("title"), row.getString("album"), row.getString("artist"))); } System.out.println();
session.execute( "CREATE TABLE simplex.songs (" + "id uuid PRIMARY KEY," + "title text," + "album text," + "artist text," + "tags set<text>," + "data blob" + ");");c. 插入数据:
session.execute( "INSERT INTO simplex.songs (id, title, album, artist, tags) " + "VALUES (" + "756716f7-2e54-4715-9f00-91dcbea6cf50," + "‘La Petite Tonkinoise‘," + "‘Bye Bye Blackbird‘," + "‘Joséphine Baker‘," + "{‘jazz‘, ‘2013‘})" + ";");d. 查询数据:
ResultSet results = session.execute("SELECT * FROM simplex.playlists "); System.out.println(String.format("%-30s\t%-20s\t%-20s\n%s", "title", "album", "artist", "-------------------------------+-----------------------+--------------------")); for (Row row : results) { System.out.println(String.format("%-30s\t%-20s\t%-20s", row.getString("title"), row.getString("album"), row.getString("artist"))); } System.out.println();
Cassandra数据库Java訪问
标签:into str clu schema rom add 2.0 lex name