-1
我目前工作的一個小的數據庫只有3個表,顯示在一個HSQL |刪除數據庫
javafx.TableView<Event>
插入一些東西到數據庫中運行的所有罰款與SQLExpression
INSERT INTO events (name, location, numberOfGuests, date) VALUES (?, ?, ?, ?)
,所以我想同樣做刪除表達這樣:
DELETE FROM events WHERE name = (name) AND location = (location) AND numberofguests = (numberOfGuests) AND date = (date) VALUES (?, ?, ?, ?)
當然,我需要收拾這一個PreparedStatement:
private static PreparedStatement getPrepStateFromEvent (Event e) throws SQLException {
//--get the attributes of the event--//
String eventName = e.getName();
String location = e.getLocation();
int numOfGuests = e.getNumberOfGuests();
Date d = e.getDate();
//--form a prepared statement--//
PreparedStatement pstmnt = conn.prepareStatement(INSERT_INTO_EVENTS);
//--enter values for the spaceholders in the pstmnt--//
pstmnt.setString(1, eventName);
pstmnt.setString(2, location);
pstmnt.setInt(3, numOfGuests);
pstmnt.setDate(4, d);
//--return--//
return pstmnt;
}
這對插入工作都很好,但不適用於刪除。你能幫我嗎?