Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void updateTask(Task task) {
- Connection con = null;
- PreparedStatement pstmt = null;
- try{
- DataSource ds = new DataSource();
- con = ds.createConnection();
- pstmt = con.prepareStatement(
- "UPDATE Tasks SET Title = ?, Priority = ?, IsComplete = ?, DateCompleted = ?, Note = ? WHERE TaskID = ?");
- pstmt.setString(1, task.getTitle());
- pstmt.setString(2, task.getPriority());
- pstmt.setInt(3, (task.getIsComplete()? 1:0));
- pstmt.setDate(4, task.getDateCompleted());
- pstmt.setString(5, task.getNote());
- pstmt.setInt(6, task.getTaskID().intValue());
- pstmt.executeUpdate();
- }
- catch(SQLException e){
- e.printStackTrace();
- }
- finally{
- try{ if(pstmt != null){ pstmt.close(); }}
- catch(SQLException ex){System.out.println(ex.getMessage());}
- try{ if(con != null){ con.close(); }}
- catch(SQLException ex){System.out.println(ex.getMessage());}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement