Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public User getUser(String login) throws DAOException{
- PreparedStatement ps = null;
- Connection con = null;
- ResultSet rs = null;
- User user = null;
- try{
- con = ConnectionPool.getInstance().getConnection();
- ps = con.prepareStatement(CommonRequest.GET_USER);
- ps.setString(1,login);
- rs = ps.executeQuery();
- if(rs.next()){
- user = new User(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getBoolean(5) ,rs.getInt(6));
- }
- }catch (ConnectionPoolException e) {
- throw new DAOException("Get connection error", e);
- }catch (SQLException e) {
- throw new DAOException("SQL Getting user exception", e);
- } finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException e) {
- logger.error("Close rs trouble");
- }
- }
- if (ps != null) {
- try {
- ps.close();
- } catch (SQLException e) {
- logger.error("Close ps trouble");
- }
- }
- if (con != null) {
- try {
- ConnectionPool.getInstance().returnConnection(con);
- } catch (ConnectionPoolException e) {
- logger.error("Return con error");
- }
- }
- }
- return user;
- }
Advertisement
Add Comment
Please, Sign In to add comment