JDBCRentABikepublic class JDBCRentABike extends org.springframework.jdbc.core.support.JdbcDaoSupport implements RentABike
Fields Summary |
---|
private String | storeName | private static final int | MANUFACTURER | private static final int | MODEL | private static final int | FRAME | private static final int | SERIALNO | private static final int | WEIGHT | private static final int | STATUS |
Methods Summary |
---|
public void | deleteBike(Bike bike)
JdbcTemplate template = getJdbcTemplate();
template.execute("DELETE FROM bikes where bikes.serialno = '" + bike.getSerialNo() + "'");
| 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.setManufacturer(rs.getString(MANUFACTURER));
bike.setModel(rs.getString(MODEL));
bike.setFrame(rs.getInt(FRAME));
bike.setSerialNo(rs.getString(SERIALNO));
bike.setWeight(rs.getDouble(WEIGHT));
bike.setStatus(rs.getString(STATUS));
}
}
template.query("SELECT * FROM bikes WHERE bikes.serialNo = '" + serialNo + "'",
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(MANUFACTURER),
rs.getString(MODEL), rs.getInt(FRAME),
rs.getString(SERIALNO), rs.getDouble(WEIGHT),
rs.getString(STATUS));
results.add(bike);
}
}
template.query("SELECT * FROM bikes", new BikesHandler());
return results;
| public java.lang.String | getStoreName()
return this.storeName;
| public void | saveBike(Bike bike)
JdbcTemplate template = getJdbcTemplate();
template.execute("DELETE FROM bikes where bikes.serialno = '" + bike.getSerialNo() + "'");
template.execute("INSERT INTO bikes (manufacturer, model, frame, serialno, weight, status) VALUES ('" + bike.getManufacturer() + "', '" + bike.getModel() + "', " + bike.getFrame() + ", '" + bike.getSerialNo() + "', " + bike.getWeight() + ", '" + bike.getStatus() + "')");
| public void | setStoreName(java.lang.String name)
this.storeName = name;
|
|