public int updateBook(Book bo) { int x = 0; try { con = JdbcUtil.getMysqlConnection(); System.out.println("update 2"); ps = con.prepareStatement( "update jlcbooks set bname=?,author=?,pub=?,cost=?,edition=?,isbn=? where bid=?"); System.out.println("update 3"); System.out.println(bo.getBid()); ps.setString(7, bo.getBid()); ps.setString(1, bo.getBname()); ps.setString(2, bo.getAuthor()); ps.setString(3, bo.getPub()); ps.setString(4, bo.getCost()); ps.setString(5, bo.getEdi()); ps.setString(6, bo.getIsbn()); x = ps.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JdbcUtil.cleanup(ps, con); } return x; }
public int addBook(Book bo) { int x = 0; try { con = JdbcUtil.getMysqlConnection(); ps = con.prepareStatement("insert into jlcbooks values(?,?,?,?,?,?,?)"); ps.setString(1, bo.getBid()); ps.setString(2, bo.getBname()); ps.setString(3, bo.getAuthor()); ps.setString(4, bo.getPub()); ps.setString(5, bo.getCost()); ps.setString(6, bo.getEdi()); ps.setString(7, bo.getIsbn()); x = ps.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { JdbcUtil.cleanup(ps, con); } return x; }