public boolean CheckUser(String username,String password)
    {
  Connection con = null;
  try 
      {
    con = pool.getConnection();
       String sql = "SELECT * from dbo.users  WHERE username = ? AND password= ?";
             
        PreparedStatement ps = null;
        ResultSet rs = null;
       
        try {
              if (con.isClosed()) {
            throw new IllegalStateException("error.con.isClosed");
          }
           ps = con.prepareStatement(sql);
           ps.setString(1,username);
           ps.setString(2,password);
           rs = ps.executeQuery();
  
          if(rs.next())
           { 
                return true;
           }
           return false;
         } catch (SQLException e) {
           e.printStackTrace();
           throw new RuntimeException("error.ps.executeQuery");
         } finally {
         try {
             if (ps != null)
                ps.close();
             if (rs != null)
                rs.close();
           } catch (SQLException e) {
              e.printStackTrace();
              throw new RuntimeException("error.rs.close");
           }
         }
    
     }
      
    catch (SQLException e) 
        {
       e.printStackTrace();
       throw new RuntimeException("Unable to get connection.");
     } 
        finally
        {
           try 
             {
         if (con != null)
           con.close();
            } 
             catch (SQLException e) 
             {
         throw new RuntimeException(e.getMessage());
            }
       }
      
  }