Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int update(User user) {
- ConnectionPool pool = ConnectionPool.getInstance();
- Connection connection = pool.getConnection();
- PreparedStatement ps = null;
- String query = "UPDATE user SET username = ?, password = ?, email = ?, firstName = ?, lastName = ?"
- + "WHERE userID = ?";
- try {
- ps = connection.prepareStatement(query);
- ps.setString(1, user.getUsername());
- ps.setString(2, user.getPassword());
- ps.setString(3, user.getEmail());
- ps.setString(4, user.getFirstName());
- ps.setString(5, user.getLastName());
- ps.setInt(6, user.getUserID());
- return ps.executeUpdate();
- } catch (SQLException e) {
- System.out.println(e);
- } finally {
- DBUtil.closePreparedStatement(ps);
- pool.freeConnection(connection);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement