Example usage for java.sql ResultSet HOLD_CURSORS_OVER_COMMIT

List of usage examples for java.sql ResultSet HOLD_CURSORS_OVER_COMMIT

Introduction

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

Prototype

int HOLD_CURSORS_OVER_COMMIT

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

Click Source Link

Document

The constant indicating that open ResultSet objects with this holdability will remain open when the current transaction is committed.

Usage

From source file:net.antidot.semantic.rdf.rdb2rdf.r2rml.core.R2RMLEngine.java

private ResultSet constructJointTable(ReferencingObjectMap refObjectMap) throws SQLException {
    log.debug("[R2RMLEngine:constructJointTable] Run joint SQL Query : " + refObjectMap.getJointSQLQuery());
    ResultSet rs = null;//from   w  w w . ja v a  2s  . co m
    java.sql.Statement s = conn.createStatement(ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY);
    if (refObjectMap.getJointSQLQuery() != null) {
        s.executeQuery(refObjectMap.getJointSQLQuery());
        rs = s.getResultSet();
        if (rs == null)
            throw new IllegalStateException("[R2RMLEngine:constructJointTable] SQL request "
                    + "failed : result of effective SQL query is null.");
    } else {
        throw new IllegalStateException(
                "[R2RMLEngine:constructJointTable] No effective SQL query has been found.");
    }
    return rs;
}

From source file:net.antidot.semantic.rdf.rdb2rdf.r2rml.core.R2RMLEngine.java

private ResultSet constructInversionTable(String instantiation, String effectiveSQLQuery) throws SQLException {
    String sqlQuery = "SELECT * FROM (" + effectiveSQLQuery + ") AS tmp WHERE " + instantiation + ";";
    log.debug("[R2RMLEngine:constructInversionTable] Run inversion SQL Query : " + sqlQuery);
    ResultSet rs = null;//from w  w w . j av  a 2 s  . c o m
    java.sql.Statement s = conn.createStatement(ResultSet.HOLD_CURSORS_OVER_COMMIT, ResultSet.CONCUR_READ_ONLY);
    s.executeQuery(sqlQuery);
    rs = s.getResultSet();
    if (rs == null)
        throw new IllegalStateException("[R2RMLEngine:constructInversionTable] SQL request "
                + "failed : result of effective SQL query is null.");
    return rs;
}

From source file:org.kawanfw.sql.jdbc.ConnectionHttp.java

/**
 * Creates a <code>PreparedStatement</code> object that will generate
 * <code>ResultSet</code> objects with the given type, concurrency, and
 * holdability./*  w  ww .ja  v  a2 s  .c  o m*/
 * <P>
 * This method is the same as the <code>prepareStatement</code> method
 * above, but it allows the default result set type, concurrency, and
 * holdability to be overridden.
 * 
 * @param sql
 *            a <code>String</code> object that is the SQL statement to be
 *            sent to the database; may contain one or more '?' IN
 *            parameters
 * @param resultSetType
 *            one of the following <code>ResultSet</code> constants:
 *            <code>ResultSet.TYPE_FORWARD_ONLY</code>,
 *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
 *            <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
 * @param resultSetConcurrency
 *            one of the following <code>ResultSet</code> constants:
 *            <code>ResultSet.CONCUR_READ_ONLY</code> or
 *            <code>ResultSet.CONCUR_UPDATABLE</code>
 * @param resultSetHoldability
 *            one of the following <code>ResultSet</code> constants:
 *            <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
 *            <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
 * @return a new <code>PreparedStatement</code> object, containing the
 *         pre-compiled SQL statement, that will generate
 *         <code>ResultSet</code> objects with the given type, concurrency,
 *         and holdability
 * @exception SQLException
 *                if a database access error occurs, this method is called
 *                on a closed connection or the given parameters are not
 *                <code>ResultSet</code> constants indicating type,
 *                concurrency, and holdability
 * @exception SQLFeatureNotSupportedException
 *                if the JDBC driver does not support this method or this
 *                method is not supported for the specified result set type,
 *                result set holdability and result set concurrency.
 * @see ResultSet
 * @since 1.4
 */
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
        int resultSetHoldability) throws SQLException {
    testIfClosed();

    // We support only ResultSet.CONCUR_READ_ONLY
    if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE) {
        throw new SQLFeatureNotSupportedException("Concurrency ResultSet.CONCUR_UPDATABLE is not supported.");
    }

    // We support only ResultSet.HOLD_CURSORS_OVER_COMMIT
    if (resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT) {
        throw new SQLFeatureNotSupportedException(
                "Concurrency ResultSet.HOLD_CURSORS_OVER_COMMIT is not supported.");
    }

    return new PreparedStatementHttp(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}

From source file:org.kawanfw.sql.jdbc.ConnectionHttp.java

/**
 * Changes the default holdability of <code>ResultSet</code> objects created
 * using this <code>Connection</code> object to the given holdability. The
 * default holdability of <code>ResultSet</code> objects can be be
 * determined by invoking {@link DatabaseMetaData#getResultSetHoldability}.
 * /*from   w  w  w . j a v  a 2 s  .c  om*/
 * @param holdability
 *            a <code>ResultSet</code> holdability constant; one of
 *            <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
 *            <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
 * @throws SQLException
 *             if a database access occurs, this method is called on a
 *             closed connection, or the given parameter is not a
 *             <code>ResultSet</code> constant indicating holdability
 * @exception SQLFeatureNotSupportedException
 *                if the given holdability is not supported
 * @see #getHoldability
 * @see DatabaseMetaData#getResultSetHoldability
 * @see ResultSet
 * @since 1.4
 */
@Override
public void setHoldability(int holdability) throws SQLException {
    testIfClosed();

    if (holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT && holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
        throw new SQLException("Illegal holdability: " + holdability);
    }

    if (!statelessMode) {
        JdbcHttpTransactionTransfer jdbcHttpTransactionTransfer = new JdbcHttpTransactionTransfer(this,
                authenticationToken);
        jdbcHttpTransactionTransfer.setHoldability(holdability);
    } else {
        if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) {
            throw new SQLFeatureNotSupportedException(
                    "holdability ResultSet.HOLD_CURSORS_OVER_COMMIT is not supported");
        }
    }

    this.holdability = holdability;
}