public void updateFields(BorrowedBook borrowedBook) throws SQLException {
Integer copiesInBorrow = new Integer(0);
Integer availableCopies = new Integer(0);
PreparedStatement pstmt;
try {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM library_students.book WHERE BookID=" + "'" + getBookID(borrowedBook)+ "'");
if((rs.next())){
copiesInBorrow=rs.getInt(11);
availableCopies=rs.getInt(13);
}
pstmt = con.prepareStatement("UPDATE library_students.book SET CopiesInBorrow= ? AND AvailableCopies=? WHERE BookID=?");
pstmt.setInt(1,++copiesInBorrow);
pstmt.setInt(2,--availableCopies);
pstmt.setString(3,getBookID(borrowedBook));
pstmt.executeUpdate();
rs.close();
}catch (SQLException ex) {
ex.printStackTrace();
}
}
I'm not getting any errors and the executeUpdate(); is returning also 1 what is the problem?
workbenchtag. Therefore I have removed them.