Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. final String INSERTFROM = "INSERT INTO priorities " +
  2. "(callId, priorityNum, employeeCod) " +
  3. "SELECT callId, priorityNum, employeeCod " +
  4. "FROM calls WHERE callId=?"; // note WHERE here
  5.  
  6. @Override
  7. public void insert(Priority o) throws DAOException {
  8. try{
  9. pstm = con.prepareStatement(INSERTFROM);
  10. /* / error under */
  11. pstm.setInt(1, o.getCallId());
  12. // no need in setting other values, since they are copied
  13. // from the calls table
  14.  
  15. if(pstm.executeUpdate() == 0 ){
  16. throw new DAOException("The update couldn't been saved");
  17. }
  18. } catch (SQLException ex) {
  19. /* And it stops here */
  20. throw new DAOException("SQL Error", ex);
  21. } finally {
  22. if(pstm != null){
  23. try {
  24. pstm.close();
  25. } catch (SQLException ex) {
  26. throw new DAOException("Error to close connection", ex);
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement