public void setDataSource(DataSource ds) {
// Initializes the in-memory database (not necessary in production)
if (!initialized) {
SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds);
jt.update("CREATE TABLE sample_table ( id INTEGER IDENTITY, str_col VARCHAR(256), num_col INTEGER)");
jt.update("INSERT INTO sample_table(str_col,num_col) VALUES('Ford', 100)");
jt.update("INSERT INTO sample_table(str_col,num_col) VALUES('Toyota', 200)");
jt.update("INSERT INTO sample_table(str_col,num_col) VALUES('Mazda', 300)");
initialized = true;
}
this.ds = ds;
}