Methods Summary |
---|
public void | deleteBike(Bike bike)
JdbcTemplate template = getJdbcTemplate();
template.execute("DELETE FROM bikes where bikes.id = " + bike.getBikeId() + "");
|
public Bike | getBike(java.lang.String serialNo)
final Bike bike = new Bike();
JdbcTemplate template = new JdbcTemplate();
template.setDataSource(this.getDataSource());
class BikeHandler implements RowCallbackHandler {
public void processRow(ResultSet rs) throws SQLException {
bike.setBikeId(rs.getInt(BIKE_ID));
bike.setManufacturer(rs.getString(BIKE_MANUFACTURER));
bike.setModel(rs.getString(BIKE_MODEL));
bike.setFrame(rs.getInt(BIKE_FRAME));
bike.setSerialNo(rs.getString(BIKE_SERIALNO));
bike.setWeight(rs.getDouble(BIKE_WEIGHT));
bike.setStatus(rs.getString(BIKE_STATUS));
}
}
template.query("SELECT * FROM bikes WHERE bikes.serialNo = '" + serialNo + "'",
new BikeHandler());
return bike;
|
public Bike | getBike(int bikeId)
final Bike bike = new Bike();
JdbcTemplate template = new JdbcTemplate();
template.setDataSource(this.getDataSource());
class BikeHandler implements RowCallbackHandler {
public void processRow(ResultSet rs) throws SQLException {
bike.setBikeId(rs.getInt(BIKE_ID));
bike.setManufacturer(rs.getString(BIKE_MANUFACTURER));
bike.setModel(rs.getString(BIKE_MODEL));
bike.setFrame(rs.getInt(BIKE_FRAME));
bike.setSerialNo(rs.getString(BIKE_SERIALNO));
bike.setWeight(rs.getDouble(BIKE_WEIGHT));
bike.setStatus(rs.getString(BIKE_STATUS));
}
}
template.query("SELECT * FROM bikes WHERE bikes.bikeId = " + bikeId,
new BikeHandler());
return bike;
|
public java.util.List | getBikes()
final ArrayList results = new ArrayList();
JdbcTemplate template = new JdbcTemplate();
template.setDataSource(this.getDataSource());
class BikesHandler implements RowCallbackHandler {
public void processRow(ResultSet rs) throws SQLException {
Bike bike = new Bike(rs.getString(BIKE_MANUFACTURER),
rs.getString(BIKE_MODEL), rs.getInt(BIKE_FRAME),
rs.getString(BIKE_SERIALNO), rs.getDouble(BIKE_WEIGHT),
rs.getString(BIKE_STATUS));
results.add(bike);
}
}
template.query("SELECT * FROM bikes", new BikesHandler());
return results;
|
public Customer | getCustomer(int custId)
final Customer customer = new Customer();
JdbcTemplate template = new JdbcTemplate();
class CustomerHandler implements RowCallbackHandler {
public void processRow(ResultSet rs) throws SQLException {
customer.setCustId(rs.getInt(CUST_ID));
customer.setFirstName(rs.getString(CUST_FIRSTNAME));
customer.setLastName(rs.getString(CUST_LASTNAME));
}
}
template.query("SELECT * FROM customers WHERE customers.custId = " + custId,
new CustomerHandler());
return customer;
|
public java.util.List | getReservations(Customer customer)
return new FindReservationsByCustomer(this.getDataSource()).
findReservations(customer.getCustId());
|
public java.util.List | getReservations(Bike bike)
return new FindReservationsByBike(this.getDataSource()).
findReservations(bike.getBikeId());
|
public java.lang.String | getStoreName()
return this.storeName;
|
public void | saveBike(Bike bike)
JdbcTemplate template = getJdbcTemplate();
Bike orig = this.getBike(bike.getSerialNo());
System.out.println(orig);
if(orig.getBikeId() == 0) {
template.execute("INSERT INTO bikes (manufacturer, model, frame, serialno, weight, status) VALUES ('" + bike.getManufacturer() + "', '" + bike.getModel() + "', " + bike.getFrame() + ", '" + bike.getSerialNo() + "', " + bike.getWeight() + ", '" + bike.getStatus() + "')");
} else {
template.execute("UPDATE bikes SET manufacturer = '" + bike.getManufacturer() + "', model = '" + bike.getModel() + "', frame = " + bike.getFrame() + ", serialno = '" + bike.getSerialNo() + "', weight = " + bike.getWeight() + ", status = '" + bike.getStatus() + "' WHERE bikeId = " + bike.getBikeId());
}
|
public void | setStoreName(java.lang.String name)
this.storeName = name;
|