private static int getCurrentVersion(Connection con, String schemaKey)
    {
        int currentVersion = -1;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            pstmt = con.prepareStatement(CHECK_VERSION);
            pstmt.setString(1, schemaKey);
            rs = pstmt.executeQuery();
            if (rs.next()) {
                currentVersion = rs.getInt(1);
            }
        }
        catch (SQLException sqle) {
            // The database schema must not be installed.
            Log.debug("SchemaManager: Error verifying "+ schemaKey +" version, probably ignorable.", sqle);
            DbConnectionManager.closeStatement(rs, pstmt);
            if (schemaKey.equals("openfire")) {
                try {
                    // Releases of Openfire before 3.6.0 stored the version in a jiveVersion table.
                    pstmt = con.prepareStatement(CHECK_VERSION_JIVE);
                    pstmt.setString(1, schemaKey);
                    rs = pstmt.executeQuery();
                    if (rs.next()) {
                        currentVersion = rs.getInt(1);
                    }
                }
                catch (SQLException sqlea) {
                    // The database schema must not be installed.
                    Log.debug("SchemaManager: Error verifying "+ schemaKey +" version, probably ignorable.", sqlea);
                    DbConnectionManager.closeStatement(rs, pstmt);

                    // Releases of Openfire before 2.6.0 stored a major and minor version
                    // number so the normal check for version can fail. Check for the
                    // version using the old format in that case.
                    try {

                        pstmt = con.prepareStatement(CHECK_VERSION_OLD);
                        rs = pstmt.executeQuery();
                        if (rs.next()) {
                            currentVersion = rs.getInt(1);
                        }
                    }
                    catch (SQLException sqle2) {
                        // The database schema must not be installed.
                        Log.debug("SchemaManager: Error verifying "+ schemaKey +" version, probably ignorable", sqle2);
                    }
                }
            }
        }
        finally {
            DbConnectionManager.closeStatement(rs, pstmt);
        }
        return currentVersion;
    }
Retrieves the version of the schema that is currently installed, or -1 if nothing is installed.
xmppserver/src/main/java/org/jivesoftware/database/SchemaManager.java