Hello all.
I have never updated a single column in a specific record.
I am using Apache derby embedded database.
I have used the update prepared statement to up date a single field with the String value but it updates all the like of every record.
How can I update a specific record’s with an int bookNum to update its status field String value? I have 2 unknown values to handle.
Statement:
<entry key="insertNewStatus">UPDATE booking SET book_status =? WHERE book_num=?</entry>
DAO: I tried this code but I just want to see how to introduce the two unknown “?” properly.
I am rewriting a few classes at the moment so I can not run it at the moment but this code compiles.
Thanks
public boolean insertNewStatus(int aBookNum,String aStatus) throws UnknownUserNameException, InterruptedException {
boolean bInserted = true;
int bookNum=aBookNum;
String status=aStatus;
setTableName(tableName);
conn = connect();
ps = (PreparedStatement) conn.prepareStatement(
ModelUtils.getXMLResource("insertNewStatus"));
ps.setString(1, status);
ps.setInt(2, bookNum);
ps.executeUpdate();
/*
* int rowCount = ps.executeUpdate();
if (rowCount != 1) {
bInserted = false;
}
*/
return bInserted;
}
Is there some code I could add here to check to see if the field was successfully updated?