Example usage for java.sql ResultSet TYPE_SCROLL_SENSITIVE

List of usage examples for java.sql ResultSet TYPE_SCROLL_SENSITIVE

Introduction

In this page you can find the example usage for java.sql ResultSet TYPE_SCROLL_SENSITIVE.

Prototype

int TYPE_SCROLL_SENSITIVE

To view the source code for java.sql ResultSet TYPE_SCROLL_SENSITIVE.

Click Source Link

Document

The constant indicating the type for a ResultSet object that is scrollable and generally sensitive to changes to the data that underlies the ResultSet.

Usage

From source file:com.chiorichan.database.DatabaseEngine.java

public ResultSet query(String query, boolean retried) throws SQLException {
    Statement stmt = null;// ww  w .  ja  v  a2s  .  c  om
    ResultSet result = null;

    if (con == null)
        throw new SQLException("The SQL connection is closed or was never opened.");

    try {
        try {
            stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        } catch (CommunicationsException e) {
            if (reconnect())
                stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        } finally {
            if (stmt == null)
                stmt = con.createStatement();
        }

        result = stmt.executeQuery(query);

        Loader.getLogger().fine("SQL Query `" + query + "` returned " + getRowCount(result) + " rows!");
    } catch (CommunicationsException | MySQLNonTransientConnectionException e) {
        if (!retried && reconnect())
            return query(query, true);
        else {
            throw e;
        }
    } catch (Throwable t) {
        t.printStackTrace();
        throw t;
    }

    return result;
}

From source file:gr.seab.r2rml.test.ComplianceTests.java

private ResultSet query(String query) {
    ResultSet result = null;// ww w .  j  a v a 2  s .  co  m

    try {
        if (connection == null)
            openConnection();

        java.sql.Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        log.info("sql query: " + query);
        result = statement.executeQuery(query);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:com.chiorichan.database.DatabaseEngine.java

public ResultSet query(String query, boolean retried, Object... args) throws SQLException {
    PreparedStatement stmt = null;
    ResultSet result = null;//from w  w  w  .  j av a  2  s.  com

    if (con == null)
        throw new SQLException("The SQL connection is closed or was never opened.");

    try {
        stmt = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

        int x = 0;

        for (Object s : args)
            try {
                x++;
                Loader.getLogger().debug(x + " -> " + ObjectUtil.castToString(s));
                stmt.setString(x, ObjectUtil.castToString(s));
            } catch (SQLException e) {
                if (!e.getMessage().startsWith("Parameter index out of range"))
                    throw e;
            }

        result = stmt.executeQuery();

        Loader.getLogger()
                .fine("SQL Query `" + stmt.toString() + "` returned " + getRowCount(result) + " rows!");
    } catch (CommunicationsException | MySQLNonTransientConnectionException e) {
        if (!retried && reconnect())
            return query(query, true, args);
        else {
            throw e;
        }
    } catch (Throwable t) {
        t.printStackTrace();
        throw t;
    }

    return result;
}

From source file:com.frostwire.database.sqlite.SQLiteDatabase.java

private PreparedStatement prepareStatement(Connection connection, String sql, Object... arguments)
        throws Exception {

    PreparedStatement statement = connection.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
            ResultSet.CONCUR_READ_ONLY);

    if (arguments != null) {
        for (int i = 0; i < arguments.length; i++) {
            statement.setObject(i + 1, arguments[i]);
        }//from  w w  w .  jav  a 2s.  co m
    }
    return statement;
}

From source file:gr.seab.r2rml.test.ComplianceTests.java

@Test
public void loadPersons() {
    if (connection == null)
        openConnection();/*from  w  ww .j a v a2s .c  om*/

    for (int i = 94300; i < 500000; i++) {
        String q1 = "INSERT INTO eperson (eperson_id, email, password, salt, digest_algorithm, firstname, lastname, can_log_in, require_certificate, self_registered, last_active, sub_frequency, phone, netid, language) "
                + "VALUES (" + i + ", 'nkons" + i
                + "@live.com', 'aa07c370f18e6306d481e29d04d28ea322f3ac5d746bd1122b4907518b37875b59283054d9e91fd049f39df2223ba3feb62f9cc2923e5614503d0b9b191d6606', '2d0155aa63818899d177ff988ddde7c5', 'SHA-512', '"
                + randomString() + "', '" + randomString()
                + "', 'true', 'false', 'false', NULL, NULL, NULL, NULL, 'en');";
        String q2 = "INSERT INTO epersongroup2eperson (id, eperson_group_id, eperson_id) VALUES (" + i + ", 1, "
                + i + ");";

        try {
            java.sql.Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                    ResultSet.CONCUR_UPDATABLE);
            int a = statement.executeUpdate(q1);
            int b = statement.executeUpdate(q2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (i % 1000 == 0)
            log.info("At " + i);
    }
}

From source file:com.tascape.reactor.report.MySqlBaseBean.java

public void setSuiteResultInvisible(String srid, boolean invisible) throws NamingException, SQLException {
    String sql = "UPDATE " + SuiteResult.TABLE_NAME + " SET " + SuiteResult.INVISIBLE_ENTRY + " = ?" + " WHERE "
            + SuiteResult.SUITE_RESULT_ID + " = ?;";
    try (Connection conn = this.getConnection()) {
        PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        stmt.setBoolean(1, invisible);/*from  w  w  w.  j a  va 2s  .c o  m*/
        stmt.setString(2, srid);
        LOG.trace("{}", stmt);
        stmt.executeUpdate();
    }
}

From source file:com.google.enterprise.connector.salesforce.storetype.DBStore.java

public DocListEntry getDocsImmediatelyAfter(String checkpoint) {
    DatabaseMetaData dbm = null;//from w  ww  .ja v  a2 s  . c o m
    Connection connection = null;

    try {

        connection = ds.getConnection();
        connection.setAutoCommit(true);

        dbm = connection.getMetaData();
        //get the most recent database row after 'checkpoint'
        if (dbm.getDatabaseProductName().equals("MySQL")) {
            Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            String update_stmt = "select crawl_set,insert_timestamp,UNCOMPRESS(crawl_data) as cdata from "
                    + this.instance_table + " where crawl_set>" + checkpoint + "  LIMIT 1";
            logger.log(Level.FINER, update_stmt);
            ResultSet rs = statement.executeQuery(update_stmt);

            boolean ret_rows = rs.first();

            if (!ret_rows) {
                logger.log(Level.FINER, "No Rows Returned.");
                connection.close();
                return null;
            }
            BigDecimal crawl_set = null;
            String crawl_data = null;
            while (ret_rows) {
                crawl_set = rs.getBigDecimal("crawl_set");
                //crawl_data = rs.getString("crawl_data");
                crawl_data = rs.getString("cdata");
                ret_rows = rs.next();
            }

            rs.close();
            statement.close();
            connection.close();

            //BASE64 DECODE 
            byte[] byte_decoded_entry = org.apache.commons.codec.binary.Base64
                    .decodeBase64(crawl_data.getBytes());
            crawl_data = new String(byte_decoded_entry);

            logger.log(Level.INFO, "Returning from DBStore. Index Value: " + crawl_set.toPlainString());
            logger.log(Level.FINEST, "Returning from DBStore. " + crawl_data);
            DocListEntry dret = new DocListEntry(crawl_set.toPlainString(), crawl_data);
            return dret;
        }
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Unable to retrieve docListEntry " + ex);
    }
    return new DocListEntry(checkpoint, null);
}

From source file:uk.ac.kcl.texthunter.core.AnnotationEditor.java

private boolean isMultiClass() throws SQLException {
    boolean isMultiClass = false;
    Statement statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = statement.executeQuery(SQLCommands.getInstance().isMultiClass());
    isMultiClass = false;/*w  ww  . j  ava2  s .  co  m*/
    while (rs.next()) {
        String classes = rs.getString(1);
        if (!classes.equalsIgnoreCase("positive") & !classes.equalsIgnoreCase("negative")
                & !classes.equalsIgnoreCase("unknown") & !classes.equalsIgnoreCase("form")) {
            isMultiClass = true;
        }
    }

    return isMultiClass;
}

From source file:org.apache.ambari.server.checks.CheckDatabaseHelper.java

protected void checkServiceConfigs() {
    String GET_SERVICES_WITHOUT_CONFIGS_QUERY = "select c.cluster_name, service_name from clusterservices cs "
            + "join clusters c on cs.cluster_id=c.cluster_id "
            + "where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id and sc.service_name=cs.service_name and sc.group_id is null)";
    String GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY = "select c.cluster_name, sc.service_name, sc.version from serviceconfig sc "
            + "join clusters c on sc.cluster_id=c.cluster_id "
            + "where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id is null";
    String GET_STACK_NAME_VERSION_QUERY = "select c.cluster_name, s.stack_name, s.stack_version from clusters c "
            + "join stack s on c.desired_stack_id = s.stack_id";
    String GET_SERVICES_WITH_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, cc.type_name, sc.version from clusterservices cs "
            + "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id "
            + "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id "
            + "join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id "
            + "join clusters c on cc.cluster_id=c.cluster_id and sc.stack_id=c.desired_stack_id "
            + "where sc.group_id is null and sc.service_config_id=(select max(service_config_id) from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id) "
            + "group by c.cluster_name, cs.service_name, cc.type_name, sc.version";
    String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, cc.type_name from clusterservices cs "
            + "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id "
            + "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id "
            + "join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id "
            + "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag and cc.cluster_id=ccm.cluster_id "
            + "join clusters c on ccm.cluster_id=c.cluster_id "
            + "where sc.group_id is null and sc.service_config_id = (select max(service_config_id) from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id) "
            + "group by c.cluster_name, cs.service_name, cc.type_name " + "having sum(ccm.selected) < 1";
    Multimap<String, String> clusterServiceMap = HashMultimap.create();
    Map<String, Map<String, String>> clusterStackInfo = new HashMap<>();
    Map<String, Multimap<String, String>> clusterServiceVersionMap = new HashMap<>();
    Map<String, Multimap<String, String>> clusterServiceConfigType = new HashMap<>();
    ResultSet rs = null;//w  w  w.j a v  a 2s. c om

    try {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);

        rs = statement.executeQuery(GET_SERVICES_WITHOUT_CONFIGS_QUERY);
        if (rs != null) {
            while (rs.next()) {
                clusterServiceMap.put(rs.getString("cluster_name"), rs.getString("service_name"));
            }

            for (String clusterName : clusterServiceMap.keySet()) {
                LOG.error("Service(s): {}, from cluster {} has no config(s) in serviceconfig table!",
                        StringUtils.join(clusterServiceMap.get(clusterName), ","), clusterName);
                errorAvailable = true;
            }

        }

        rs = statement.executeQuery(GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY);
        if (rs != null) {
            String serviceName = null, version = null, clusterName = null;
            while (rs.next()) {
                serviceName = rs.getString("service_name");
                clusterName = rs.getString("cluster_name");
                version = rs.getString("version");

                if (clusterServiceVersionMap.get(clusterName) != null) {
                    Multimap<String, String> serviceVersion = clusterServiceVersionMap.get(clusterName);
                    serviceVersion.put(serviceName, version);
                } else {
                    Multimap<String, String> serviceVersion = HashMultimap.create();
                    ;
                    serviceVersion.put(serviceName, version);
                    clusterServiceVersionMap.put(clusterName, serviceVersion);
                }
            }

            for (String clName : clusterServiceVersionMap.keySet()) {
                Multimap<String, String> serviceVersion = clusterServiceVersionMap.get(clName);
                for (String servName : serviceVersion.keySet()) {
                    LOG.error(
                            "In cluster {}, service config mapping is unavailable (in table serviceconfigmapping) for service {} with version(s) {}! ",
                            clName, servName, StringUtils.join(serviceVersion.get(servName), ","));
                    errorAvailable = true;
                }
            }

        }

        //get stack info from db
        rs = statement.executeQuery(GET_STACK_NAME_VERSION_QUERY);
        if (rs != null) {
            while (rs.next()) {
                Map<String, String> stackInfoMap = new HashMap<>();
                stackInfoMap.put(rs.getString("stack_name"), rs.getString("stack_version"));
                clusterStackInfo.put(rs.getString("cluster_name"), stackInfoMap);
            }
        }

        Set<String> serviceNames = new HashSet<>();
        Map<String, Map<Integer, Multimap<String, String>>> dbClusterServiceVersionConfigs = new HashMap<>();
        Multimap<String, String> stackServiceConfigs = HashMultimap.create();

        rs = statement.executeQuery(GET_SERVICES_WITH_CONFIGS_QUERY);
        if (rs != null) {
            String serviceName = null, configType = null, clusterName = null;
            Integer serviceVersion = null;
            while (rs.next()) {
                clusterName = rs.getString("cluster_name");
                serviceName = rs.getString("service_name");
                configType = rs.getString("type_name");
                serviceVersion = rs.getInt("version");

                serviceNames.add(serviceName);

                //collect data about mapped configs to services from db
                if (dbClusterServiceVersionConfigs.get(clusterName) != null) {
                    Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = dbClusterServiceVersionConfigs
                            .get(clusterName);

                    if (dbServiceVersionConfigs.get(serviceVersion) != null) {
                        dbServiceVersionConfigs.get(serviceVersion).put(serviceName, configType);
                    } else {
                        Multimap<String, String> dbServiceConfigs = HashMultimap.create();
                        dbServiceConfigs.put(serviceName, configType);
                        dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
                    }
                } else {
                    Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = new HashMap<>();
                    Multimap<String, String> dbServiceConfigs = HashMultimap.create();
                    dbServiceConfigs.put(serviceName, configType);
                    dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
                    dbClusterServiceVersionConfigs.put(clusterName, dbServiceVersionConfigs);
                }
            }
        }

        //compare service configs from stack with configs that we got from db
        for (Map.Entry<String, Map<String, String>> clusterStackInfoEntry : clusterStackInfo.entrySet()) {
            //collect required configs for all services from stack
            String clusterName = clusterStackInfoEntry.getKey();
            Map<String, String> stackInfo = clusterStackInfoEntry.getValue();
            String stackName = stackInfo.keySet().iterator().next();
            String stackVersion = stackInfo.get(stackName);
            Map<String, ServiceInfo> serviceInfoMap = ambariMetaInfo.getServices(stackName, stackVersion);
            for (String serviceName : serviceNames) {
                ServiceInfo serviceInfo = serviceInfoMap.get(serviceName);
                Set<String> configTypes = serviceInfo.getConfigTypeAttributes().keySet();
                for (String configType : configTypes) {
                    stackServiceConfigs.put(serviceName, configType);
                }
            }

            //compare required service configs from stack with mapped service configs from db
            Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = dbClusterServiceVersionConfigs
                    .get(clusterName);
            for (Integer serviceVersion : dbServiceVersionConfigs.keySet()) {
                Multimap<String, String> dbServiceConfigs = dbServiceVersionConfigs.get(serviceVersion);
                for (String serviceName : dbServiceConfigs.keySet()) {
                    Collection<String> serviceConfigsFromStack = stackServiceConfigs.get(serviceName);
                    Collection<String> serviceConfigsFromDB = dbServiceConfigs.get(serviceName);
                    if (serviceConfigsFromDB != null && serviceConfigsFromStack != null) {
                        serviceConfigsFromStack.removeAll(serviceConfigsFromDB);
                        if (!serviceConfigsFromStack.isEmpty()) {
                            LOG.error(
                                    "Required config(s): {} is(are) not available for service {} with service config version {} in cluster {}",
                                    StringUtils.join(serviceConfigsFromStack, ","), serviceName,
                                    Integer.toString(serviceVersion), clusterName);
                            errorAvailable = true;
                        }
                    }
                }
            }
        }

        //getting services which has mapped configs which are not selected in clusterconfigmapping
        rs = statement.executeQuery(GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY);
        if (rs != null) {
            String serviceName = null, configType = null, clusterName = null;
            while (rs.next()) {
                clusterName = rs.getString("cluster_name");
                serviceName = rs.getString("service_name");
                configType = rs.getString("type_name");

                if (clusterServiceConfigType.get(clusterName) != null) {
                    Multimap<String, String> serviceConfigs = clusterServiceConfigType.get(clusterName);
                    serviceConfigs.put(serviceName, configType);
                } else {

                    Multimap<String, String> serviceConfigs = HashMultimap.create();
                    serviceConfigs.put(serviceName, configType);
                    clusterServiceConfigType.put(clusterName, serviceConfigs);

                }

            }
        }

        for (String clusterName : clusterServiceConfigType.keySet()) {
            Multimap<String, String> serviceConfig = clusterServiceConfigType.get(clusterName);
            for (String serviceName : serviceConfig.keySet()) {
                LOG.error("You have non selected configs: {} for service {} from cluster {}!",
                        StringUtils.join(serviceConfig.get(serviceName), ","), serviceName, clusterName);
                errorAvailable = true;
            }
        }
    } catch (SQLException e) {
        LOG.error("Exception occurred during complex service check procedure: ", e);
    } catch (AmbariException e) {
        LOG.error("Exception occurred during complex service check procedure: ", e);
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                LOG.error("Exception occurred during result set closing procedure: ", e);
            }
        }
    }

}

From source file:com.tascape.reactor.report.MySqlBaseBean.java

public void importJson(JSONObject json) throws NamingException, SQLException {
    JSONObject sr = json.getJSONObject("suite_result");
    String srid = sr.getString(SuiteResult.SUITE_RESULT_ID);
    LOG.debug("srid {}", srid);

    try (Connection conn = this.getConnection()) {
        String sql = "SELECT * FROM " + SuiteResult.TABLE_NAME + " WHERE " + SuiteResult.SUITE_RESULT_ID
                + " = ?;";
        PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        stmt.setString(1, srid);//from   w w  w.ja v  a  2  s.com
        ResultSet rs = stmt.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();
        if (rs.first()) {
            LOG.debug("already imported {}", srid);
            return;
        }
        rs.moveToInsertRow();
        for (int col = 1; col <= rsmd.getColumnCount(); col++) {
            String cn = rsmd.getColumnLabel(col);
            rs.updateObject(cn, sr.opt(cn));
        }
        rs.insertRow();
        rs.last();
        rs.updateRow();
        LOG.debug("sr imported");
    }

    try (Connection conn = this.getConnection()) {
        String sql = "SELECT * FROM " + SuiteProperty.TABLE_NAME + " WHERE " + SuiteProperty.SUITE_RESULT_ID
                + " = ?;";
        PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        stmt.setString(1, srid);
        ResultSet rs = stmt.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();

        JSONArray sps = sr.getJSONArray("suite_properties");
        int len = sps.length();
        for (int i = 0; i < len; i++) {
            rs.moveToInsertRow();
            JSONObject tr = sps.getJSONObject(i);
            for (int col = 1; col <= rsmd.getColumnCount(); col++) {
                String cn = rsmd.getColumnLabel(col);
                if (SuiteProperty.SUITE_PROPERTY_ID.equals(cn)) {
                    continue;
                }
                rs.updateObject(cn, tr.get(cn));
            }
            rs.insertRow();
            rs.last();
            rs.updateRow();
        }
        LOG.debug("sps imported");
    }

    JSONArray trs = sr.getJSONArray("case_results");
    int len = trs.length();

    try (Connection conn = this.getConnection()) {
        String sql = String.format("SELECT * FROM %s WHERE %s=? AND %s=? AND %s=? AND %s=? AND %s=?;",
                TaskCase.TABLE_NAME, TaskCase.SUITE_CLASS, TaskCase.CASE_CLASS, TaskCase.CASE_METHOD,
                TaskCase.CASE_DATA_INFO, TaskCase.CASE_DATA);
        PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        stmt.setMaxRows(1);
        for (int i = 0; i < len; i++) {
            JSONObject tr = trs.getJSONObject(i);
            stmt.setString(1, tr.getString(TaskCase.SUITE_CLASS));
            stmt.setString(2, tr.getString(TaskCase.CASE_CLASS));
            stmt.setString(3, tr.getString(TaskCase.CASE_METHOD));
            stmt.setString(4, tr.getString(TaskCase.CASE_DATA_INFO));
            stmt.setString(5, tr.getString(TaskCase.CASE_DATA));
            ResultSet rs = stmt.executeQuery();
            if (!rs.first()) {
                rs.moveToInsertRow();
                rs.updateString(TaskCase.SUITE_CLASS, tr.getString(TaskCase.SUITE_CLASS));
                rs.updateString(TaskCase.CASE_CLASS, tr.getString(TaskCase.CASE_CLASS));
                rs.updateString(TaskCase.CASE_METHOD, tr.getString(TaskCase.CASE_METHOD));
                rs.updateString(TaskCase.CASE_DATA_INFO, tr.getString(TaskCase.CASE_DATA_INFO));
                rs.updateString(TaskCase.CASE_DATA, tr.getString(TaskCase.CASE_DATA));
                rs.insertRow();
                rs.last();
                rs.updateRow();
                rs = stmt.executeQuery();
                rs.first();
            }
            tr.put(TaskCase.TASK_CASE_ID, rs.getLong(TaskCase.TASK_CASE_ID));
        }
        LOG.debug("tcid updated");
    }

    try (Connection conn = this.getConnection()) {
        String sql = "SELECT * FROM " + CaseResult.TABLE_NAME + " WHERE " + CaseResult.SUITE_RESULT + " = ?;";
        PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        stmt.setString(1, srid);
        ResultSet rs = stmt.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();
        for (int i = 0; i < len; i++) {
            rs.moveToInsertRow();
            JSONObject tr = trs.getJSONObject(i);
            for (int col = 1; col <= rsmd.getColumnCount(); col++) {
                String cn = rsmd.getColumnLabel(col);
                rs.updateObject(cn, tr.opt(cn));
            }
            rs.insertRow();
            rs.last();
            rs.updateRow();
        }
        LOG.debug("crs imported");
    }

    try (Connection conn = this.getConnection()) {
        String sql = "SELECT * FROM " + CaseResultMetric.TABLE_NAME + ";";
        PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        stmt.setMaxRows(1);
        ResultSet rs = stmt.executeQuery();
        ResultSetMetaData rsmd = rs.getMetaData();
        for (int i = 0; i < len; i++) {
            JSONArray jarr = trs.getJSONObject(i).optJSONArray("CASE_result_metrics");
            if (jarr == null) {
                continue;
            }
            int l = jarr.length();
            for (int j = 0; j < l; j++) {
                JSONObject trm = jarr.getJSONObject(j);
                rs.moveToInsertRow();
                for (int col = 1; col <= rsmd.getColumnCount(); col++) {
                    String cn = rsmd.getColumnLabel(col);
                    if (cn.equals(CaseResultMetric.CASE_RESULT_METRIC_ID)) {
                        continue;
                    }
                    rs.updateObject(cn, trm.get(cn));
                }
                rs.insertRow();
                rs.last();
                rs.updateRow();
            }
        }
        LOG.debug("crms imported");
    }
}