Example usage for java.sql ResultSet CONCUR_READ_ONLY

List of usage examples for java.sql ResultSet CONCUR_READ_ONLY

Introduction

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

Prototype

int CONCUR_READ_ONLY

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

Click Source Link

Document

The constant indicating the concurrency mode for a ResultSet object that may NOT be updated.

Usage

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AttachmentTagTable.java

public MSSBamAttachmentTagBuff[] readBuffByAttachmentIdx(MSSBamAuthorization Authorization, long AttachmentId) {
    final String S_ProcName = "readBuffByAttachmentIdx";
    try {//from   w  ww. j  a  v  a  2  s . c  o m
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAttachmentTagBuff + "WHERE " + "attg.AttachmentId = "
                + Long.toString(AttachmentId) + " " + "ORDER BY " + "attg.AttachmentId ASC" + ", "
                + "attg.TagId ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamAttachmentTagBuff> buffList = new ArrayList<MSSBamAttachmentTagBuff>();
        while (resultSet.next()) {
            MSSBamAttachmentTagBuff buff = unpackAttachmentTagResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamAttachmentTagBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:br.org.indt.ndg.server.client.TemporaryOpenRosaBussinessDelegate.java

/********** Downloading OpenRosa Surveys List and specific surveys **********/

public String getFormattedSurveyAvailableToDownloadList(String imei) {
    String result = null;/*from   w  w  w . j a va  2s  . co m*/
    PreparedStatement listSurveysToDownloadStmt = null;
    Connection conn = null;
    try {
        conn = getDbConnection();
        listSurveysToDownloadStmt = conn.prepareStatement(SELECT_SURVEYS_AVAILABLE_FOR_USER_STATEMENT,
                ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        listSurveysToDownloadStmt.setString(1, imei);
        ResultSet results = listSurveysToDownloadStmt.executeQuery();
        OpenRosaSurveysList list = new OpenRosaSurveysList(results);
        result = list.toString();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        try {
            listSurveysToDownloadStmt.close();
            conn.close();
        } catch (Exception e) {
        }
    }
    return result;
}

From source file:com.nridge.core.ds.rdbms.hsqldb.HDBSQLTable.java

private void query(String aSQLStatement, DataTable aTable, int aLimit) throws NSException {
    Logger appLogger = mAppMgr.getLogger(this, "query");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    Statement stmtQuery = null;/*  ww  w .ja  v  a 2s .com*/
    appLogger.debug(aSQLStatement);
    Connection jdbcConnection = mSQLConnection.getJDBCConnection();
    try {
        stmtQuery = jdbcConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        if (aLimit > 0)
            stmtQuery.setFetchSize(aLimit);
        stmtQuery.setEscapeProcessing(mSQLConnection.isStatementEscapingEnabled());
        mSQLConnection.setLastStatement(aSQLStatement);
        ResultSet resultSet = stmtQuery.executeQuery(aSQLStatement);
        while (resultSet.next())
            addTableRowFromResultSet(aTable, resultSet);
    } catch (SQLException e) {
        throw new NSException("RDBMS Query Error: " + aSQLStatement + " : " + e.getMessage(), e);
    } finally {
        if (stmtQuery != null) {
            try {
                stmtQuery.close();
            } catch (SQLException ignored) {
            }
        }
    }

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);
}

From source file:edu.ku.brc.specify.conversion.IdHashMapper.java

/**
 * Cleans up temporary data.//from   ww  w .j a va2 s. co m
 */
public void cleanup() {
    closeSQLStatements();

    if (mapTableName != null && doDelete) {
        try {
            Statement stmt = oldConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            stmt.executeUpdate("DROP TABLE `" + mapTableName + "`");
            stmt.close();

        } catch (com.mysql.jdbc.exceptions.MySQLSyntaxErrorException ex) {
            log.error(ex);

        } catch (Exception ex) {
            //ex.printStackTrace();
            log.error(ex);
        }
        mapTableName = null;
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AccessSecurityTable.java

public void updateAccessSecurity(MSSBamAuthorization Authorization, MSSBamAccessSecurityBuff Buff) {
    final String S_ProcName = "updateAccessSecurity";
    try {/*from   w w  w  . ja v a  2 s.  c  om*/
        Connection cnx = schema.getCnx();
        short Id = Buff.getRequiredId();
        String Name = Buff.getRequiredName();

        int Revision = Buff.getRequiredRevision();
        MSSBamAccessSecurityBuff readBuff = readBuffByIdIdx(Authorization, Id);
        int oldRevision = readBuff.getRequiredRevision();
        if (oldRevision != Revision) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), S_ProcName,
                    Buff);
        }
        int newRevision = Revision + 1;
        String sql = "UPDATE mssbam110.accsec " + "SET " + "Id = " + MSSBamPg8Schema.getInt16String(Id) + ", "
                + "Name = " + MSSBamPg8Schema.getQuotedString(Name) + ", " + "Revision = "
                + Integer.toString(newRevision) + " " + "WHERE " + "Id = " + Short.toString(Id) + " " + "AND "
                + "Revision = " + Integer.toString(Revision);
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        int rowsAffected = stmt.executeUpdate(sql);
        if (rowsAffected != 1) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 row to be affected by update, not " + rowsAffected);
        }
        Buff.setRequiredRevision(newRevision);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AccessFrequencyTable.java

public void updateAccessFrequency(MSSBamAuthorization Authorization, MSSBamAccessFrequencyBuff Buff) {
    final String S_ProcName = "updateAccessFrequency";
    try {//from  www  .  j a  v  a  2s  .co m
        Connection cnx = schema.getCnx();
        short Id = Buff.getRequiredId();
        String Name = Buff.getRequiredName();

        int Revision = Buff.getRequiredRevision();
        MSSBamAccessFrequencyBuff readBuff = readBuffByIdIdx(Authorization, Id);
        int oldRevision = readBuff.getRequiredRevision();
        if (oldRevision != Revision) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), S_ProcName,
                    Buff);
        }
        int newRevision = Revision + 1;
        String sql = "UPDATE mssbam110.accfreq " + "SET " + "Id = " + MSSBamPg8Schema.getInt16String(Id) + ", "
                + "Name = " + MSSBamPg8Schema.getQuotedString(Name) + ", " + "Revision = "
                + Integer.toString(newRevision) + " " + "WHERE " + "Id = " + Short.toString(Id) + " " + "AND "
                + "Revision = " + Integer.toString(Revision);
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        int rowsAffected = stmt.executeUpdate(sql);
        if (rowsAffected != 1) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 row to be affected by update, not " + rowsAffected);
        }
        Buff.setRequiredRevision(newRevision);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:fr.cnes.sitools.datasource.jdbc.business.SitoolsDataSource.java

/**
 * Make the SQL request starting at offset and returning maxrows records
 * //from  w  w w.j  a  va2 s  . co m
 * 
 * @param sql
 *          SQL request
 * @param maxrows
 *          the maximal number of rows
 * @param offset
 *          the offset in rows
 * @return ResultSet
 */
public ResultSet limitedQuery(String sql, int maxrows, int offset) {
    Connection conn = null;
    ResultSet rs = null;
    try {
        String sqlCompleted = addLimitOffset(sql, maxrows, offset);
        conn = getConnection();

        if (conn == null) {
            LOG.log(Level.WARNING, "getConnection failed");
            return null;
        }

        // modif inspir par le LAM
        LOG.log(Level.INFO, "Limited query = " + sqlCompleted);
        // set autocommit false to enable the use of cursors
        conn.setAutoCommit(false);
        // Cela permet d'utiliser les mcanismes de streaming de JDBC
        PreparedStatement prep = conn.prepareStatement(sqlCompleted, ResultSet.TYPE_FORWARD_ONLY,
                ResultSet.CONCUR_READ_ONLY); // ,

        if (prep == null) {
            LOG.log(Level.WARNING, "prepareStatement failed");
            return null;
        }
        int fetchSize = SitoolsSettings.getInstance().getInt("Starter.JDBC_FETCH_SIZE");
        // modif inspire par le LAM
        // On positionne la taille de chaque streaming
        prep.setFetchSize(fetchSize);
        prep.setFetchDirection(ResultSet.FETCH_FORWARD);

        rs = prep.executeQuery();

        return new DBResultSet(rs, prep, conn);

    } catch (SQLException ex) {
        LOG.log(Level.SEVERE, null, ex);
        closeConnection(conn);
        closeResultSet(rs);
        conn = null;
    } catch (RuntimeException ex) {
        LOG.log(Level.SEVERE, null, ex);
        closeConnection(conn);
        closeResultSet(rs);
    } catch (Exception ex) {
        LOG.log(Level.SEVERE, null, ex);
        closeConnection(conn);
        closeResultSet(rs);
        conn = null;
    }
    return null;
}

From source file:org.ala.lucene.ExternalIndexLoader.java

/**
 * Load the data providers//from  ww  w  .ja  v  a  2 s . c o m
 * 
 * @throws Exception
 */
public void loadDataProviders() throws Exception {

    logger.info("Started syncing data provider information....");
    Connection conn = collectoryDataSource.getConnection();
    Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    ResultSet rs = stmt
            .executeQuery("select dp.uid, dp.name, dp.pub_description as description from data_provider dp");

    SolrServer solrServer = solrUtils.getSolrServer();
    solrServer.deleteByQuery("idxtype:" + IndexedTypes.DATAPROVIDER);

    while (rs.next()) {
        String uid = rs.getString("uid");
        String name = rs.getString("name");
        String description = rs.getString("description");

        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("guid", baseUrlForCollectory + uid);
        doc.addField("url", baseUrlForCollectory + uid);
        doc.addField("id", baseUrlForCollectory + uid);
        doc.addField("name", name);
        doc.addField("description", description);
        doc.addField("idxtype", IndexedTypes.DATAPROVIDER);
        //         doc.addField("aus_s", "yes");
        doc.addField("australian_s", "recorded"); // so they appear in default QF search
        solrServer.add(doc);
    }

    solrServer.commit();
    rs.close();
    stmt.close();
    conn.close();
    logger.info("Finished syncing data provider information.");
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AddressTable.java

public MSSBamAddressBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long AddressId) {
    final String S_ProcName = "readBuffByIdIdx";
    try {/*from w  w  w .j  ava 2s . c  o  m*/
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAddressBuff + "WHERE " + "adr.AddressId = " + Long.toString(AddressId) + " ";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        if (resultSet.next()) {
            MSSBamAddressBuff buff = unpackAddressResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected");
            }
            return (buff);
        } else {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AddressTagTable.java

public MSSBamAddressTagBuff[] readBuffByTagIdx(MSSBamAuthorization Authorization, long TagId) {
    final String S_ProcName = "readBuffByTagIdx";
    try {/* www .  j a  v  a2  s.  c o m*/
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAddressTagBuff + "WHERE " + "adtg.TagId = " + Long.toString(TagId) + " "
                + "ORDER BY " + "adtg.AddressId ASC" + ", " + "adtg.TagId ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamAddressTagBuff> buffList = new ArrayList<MSSBamAddressTagBuff>();
        while (resultSet.next()) {
            MSSBamAddressTagBuff buff = unpackAddressTagResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamAddressTagBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}