Database Reference
In-Depth Information
'SimpleStrategy', " +
"'replication_factor': 1 };");
session.execute("CREATE TABLE IF NOT EXISTS port-
folio (" +
"portfolio_id UUID, ticker TEXT,
" +
"current_price DECIMAL, cur-
rent_change DECIMAL, " +
"current_change_percent FLOAT, "
+
"PRIMARY KEY(portfolio_id, tick-
er);");
}
Writing Data
Once our schema has been created, we can load in some data. In this example,
we will add a couple of rows to our table. Listing 9.5 shows example insert state-
ments.
Listing 9.5 Writing Data in Java
Click here to view code image
public void loadData(){
session.execute("INSERT INTO portfo-
lio_demo.portfolio " +
"(portfolio_id, ticker, cur-
rent_price, " +
" current_change, cur-
rent_change_percent) VALUES " +
"(756716f7-2e54-4715-9f00-91dcbea6cf50,
'GOOG', " +
" 889.07, -4.00, -0.45);");
session.execute("INSERT INTO portfo-
lio_demo.portfolio " +
"(portfolio_id, ticker, cur-
rent_price, " +
 
Search WWH ::




Custom Search