public int countRows(String query) {
        ResultSet rs = null;
        int rowCount = 0;
        try {
            Statement statement = conn.createStatement();
            // select the number of rows in the table
            rs = statement.executeQuery(query);
            // get the number of rows from the result set
            if (rs.next())
            {
                if (rs.getInt("userCount") > 0)
                {
                    rowCount = 1;
                }
            } else {
                rowCount = 0;
            }
            statement.close();
            return rowCount;
        } catch (SQLException e) {
            e.printStackTrace();
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException e1) {
                    System.err.println ("MySQL Error (2): " + e1.toString());
                }
            }
            return rowCount;
        }
    }