public boolean checkDuplicateLoan(String memberID, String loantype)
    {
        String query = "";
        if(!loantype.equals("A")) {
            query = "select * from loan_hdr where memberid="+memberID+" and status='ACTIVE' and loantype='"+loantype+"'";
        }
        else
            query = "select * from cashloan where memberid="+memberID+" and status='ACTIVE'";
        
        PreparedStatement stmt = null;
        Connection con = null;
        ResultSet rs;

        try {
            try {
                Class.forName(DATABASE_CLASS);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(ConnectToDatabaseSys.class.getName()).log(Level.SEVERE, null, ex);
            }
        con = DriverManager.getConnection (DATABASE_URL, DATABASE_NAME, DATABASE_PASSWORD);
        stmt = con.prepareStatement(query);
        }
                
	catch (SQLException e) { }
        
        try {
            rs = stmt.executeQuery(query);
            if(!rs.next())
            {
                con.close();
                return true;
            }            
	}
        catch (SQLException e) {
            e.printStackTrace();
	} 
        finally{
            try {
                con.close();
            } 
            catch (SQLException ex) {
                Logger.getLogger(ConnectToDatabaseSys.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return false;
    }