Example usage for java.sql ResultSet CONCUR_UPDATABLE

List of usage examples for java.sql ResultSet CONCUR_UPDATABLE

Introduction

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

Prototype

int CONCUR_UPDATABLE

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

Click Source Link

Document

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

Usage

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./*from  w w w . ja va  2  s.  co 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:uk.ac.kcl.texthunter.core.AnnotationEditor.java

private void setUpActiveLearningTempTable() throws SQLException {

    Statement stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    try {//from   w ww .  ja va 2 s  .c o  m
        stmt1.execute("DROP TABLE " + targetTableName + "_TEMPAL");
    } catch (SQLException ex) {
        System.out.println(ex);
        System.out.println("Drop of temp table failed. It probably doesn't exist yet");
    }
    stmt1.execute("select   t1.id into " + targetTableName + "_TEMPAL   \n " + " FROM " + targetTableName
            + " t1 \n " + "  inner join \n " + " ( \n " + " select distinct contextString, min(id) as id from "
            + targetTableName + " \n " + "  group by contextString \n " + " ) as b\n "
            + " on t1.contextString = b.contextString\n " + " and t1.id = b.id ");

}

From source file:org.apache.hive.jdbc.TestJdbcDriver2.java

/**
 * Negative Test for cursor repositioning to start of resultset
 * Verify unsupported JDBC resultset attributes
 * @throws Exception//from ww  w.  j  a v  a  2 s.  c o  m
 */
@Test
public void testUnsupportedFetchTypes() throws Exception {
    try {
        con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        fail("createStatement with TYPE_SCROLL_SENSITIVE should fail");
    } catch (SQLException e) {
        assertEquals("HYC00", e.getSQLState().trim());
    }

    try {
        con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        fail("createStatement with CONCUR_UPDATABLE should fail");
    } catch (SQLException e) {
        assertEquals("HYC00", e.getSQLState().trim());
    }
}

From source file:net.starschema.clouddb.jdbc.BQDatabaseMetadata.java

/**
 * <p>/*from   www  .  ja  v a2  s  . c  om*/
 * <h1>Implementation Details:</h1><br>
 * Returns false
 * </p>
 */
@Override
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
    if (ResultSet.TYPE_FORWARD_ONLY == type) {
        if (ResultSet.CONCUR_READ_ONLY == concurrency) {
            return true;
        }
        if (ResultSet.CONCUR_UPDATABLE == concurrency) {
            return false;
        }
    }

    if (ResultSet.TYPE_SCROLL_INSENSITIVE == type) {
        if (ResultSet.CONCUR_READ_ONLY == concurrency) {
            return true;
        }
        if (ResultSet.CONCUR_UPDATABLE == concurrency) {
            return false;
        }
    }

    if (ResultSet.TYPE_SCROLL_SENSITIVE == type) {
        if (ResultSet.CONCUR_READ_ONLY == concurrency) {
            return true;
        }
        if (ResultSet.CONCUR_UPDATABLE == concurrency) {
            return false;
        }
    }
    return false;
}

From source file:org.apache.openjpa.jdbc.sql.DBDictionary.java

public void updateBlob(Select sel, JDBCStore store, InputStream is) throws SQLException {
    SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration());
    ResultSet res = null;//from  w  ww .  j  a v  a2s  . c  om
    Connection conn = store.getConnection();
    PreparedStatement stmnt = null;
    try {
        stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(), ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        setTimeouts(stmnt, store.getFetchConfiguration(), true);
        res = stmnt.executeQuery();
        if (!res.next()) {
            throw new InternalException(_loc.get("stream-exception"));
        }
        Blob blob = res.getBlob(1);
        OutputStream os = blob.setBinaryStream(1);
        copy(is, os);
        os.close();
        res.updateBlob(1, blob);
        res.updateRow();

    } catch (IOException ioe) {
        throw new StoreException(ioe);
    } finally {
        if (res != null)
            try {
                res.close();
            } catch (SQLException e) {
            }
        if (stmnt != null)
            try {
                stmnt.close();
            } catch (SQLException e) {
            }
        if (conn != null)
            try {
                conn.close();
            } catch (SQLException e) {
            }
    }
}

From source file:org.apache.openjpa.jdbc.sql.DBDictionary.java

public void updateClob(Select sel, JDBCStore store, Reader reader) throws SQLException {
    SQLBuffer sql = sel.toSelect(true, store.getFetchConfiguration());
    ResultSet res = null;//from   w w w. j  a  v  a  2  s.co m
    Connection conn = store.getConnection();
    PreparedStatement stmnt = null;
    try {
        stmnt = sql.prepareStatement(conn, store.getFetchConfiguration(), ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_UPDATABLE);
        setTimeouts(stmnt, store.getFetchConfiguration(), true);
        res = stmnt.executeQuery();
        if (!res.next()) {
            throw new InternalException(_loc.get("stream-exception"));
        }
        Clob clob = res.getClob(1);
        if (clob != null) {
            Writer writer = clob.setCharacterStream(1);
            copy(reader, writer);
            writer.close();
            res.updateClob(1, clob);
            res.updateRow();
        }

    } catch (IOException ioe) {
        throw new StoreException(ioe);
    } finally {
        if (res != null)
            try {
                res.close();
            } catch (SQLException e) {
            }
        if (stmnt != null)
            try {
                stmnt.close();
            } catch (SQLException e) {
            }
        if (conn != null)
            try {
                conn.close();
            } catch (SQLException e) {
            }
    }
}