Search in sources :

Example 26 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project ignite by apache.

the class JdbcConnection method createStatement.

/** {@inheritDoc} */
@Override
public Statement createStatement(int resSetType, int resSetConcurrency, int resSetHoldability) throws SQLException {
    ensureNotClosed();
    if (resSetType != TYPE_FORWARD_ONLY)
        throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)");
    if (resSetConcurrency != CONCUR_READ_ONLY)
        throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported).");
    if (!txAllowed && resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
        throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
    JdbcStatement stmt = new JdbcStatement(this);
    statements.add(stmt);
    return stmt;
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException)

Example 27 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project ignite by apache.

the class JdbcConnection method prepareStatement.

/** {@inheritDoc} */
@Override
public PreparedStatement prepareStatement(String sql, int resSetType, int resSetConcurrency, int resSetHoldability) throws SQLException {
    ensureNotClosed();
    if (resSetType != TYPE_FORWARD_ONLY)
        throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)");
    if (resSetConcurrency != CONCUR_READ_ONLY)
        throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported).");
    if (!txAllowed && resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
        throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
    JdbcPreparedStatement stmt;
    if (!stream)
        stmt = new JdbcPreparedStatement(this, sql);
    else {
        GridQueryIndexing idx = ignite().context().query().getIndexing();
        PreparedStatement nativeStmt = prepareNativeStatement(sql);
        if (!idx.isInsertStatement(nativeStmt))
            throw new IgniteSQLException("Only INSERT operations are supported in streaming mode", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
        IgniteDataStreamer streamer = ignite().dataStreamer(cacheName);
        streamer.autoFlushFrequency(streamFlushTimeout);
        streamer.allowOverwrite(streamAllowOverwrite);
        if (streamNodeBufSize > 0)
            streamer.perNodeBufferSize(streamNodeBufSize);
        if (streamNodeParOps > 0)
            streamer.perNodeParallelOperations(streamNodeParOps);
        stmt = new JdbcStreamedPreparedStatement(this, sql, streamer, nativeStmt);
    }
    statements.add(stmt);
    return stmt;
}
Also used : IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) PreparedStatement(java.sql.PreparedStatement) GridQueryIndexing(org.apache.ignite.internal.processors.query.GridQueryIndexing)

Example 28 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project jena by apache.

the class JenaStatement method getMoreResults.

@Override
public boolean getMoreResults(int current) throws SQLException {
    if (this.isClosed())
        throw new SQLException("The Statement is closed");
    switch(current) {
        case Statement.CLOSE_CURRENT_RESULT:
            return this.getMoreResults();
        case Statement.CLOSE_ALL_RESULTS:
            for (ResultSet rset : this.openResults) {
                rset.close();
            }
            this.openResults.clear();
            return this.getMoreResults();
        case Statement.KEEP_CURRENT_RESULT:
            if (this.currResults != null) {
                this.openResults.add(this.currResults);
                this.currResults = null;
            }
            return this.getMoreResults();
        default:
            throw new SQLFeatureNotSupportedException("Unsupported mode for dealing with current results, only Statement.CLOSE_CURRENT_RESULT, Statement.CLOSE_ALL_RESULTS and Statement.KEEP_CURRENT_RESULT are supported");
    }
}
Also used : SQLException(java.sql.SQLException) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) ResultSet(java.sql.ResultSet)

Example 29 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project phoenix by apache.

the class PhoenixRuntime method getFirstPKColumnExpression.

private static Expression getFirstPKColumnExpression(PTable table) throws SQLException {
    if (table.getIndexType() == IndexType.LOCAL) {
        /*
             * With some hackery, we could deduce the tenant ID from a multi-tenant local index,
             * however it's not clear that we'd want to maintain the same prefixing of the region
             * start key, as the region boundaries may end up being different on a cluster being
             * replicated/backed-up to (which is the use case driving the method).
             */
        throw new SQLFeatureNotSupportedException();
    }
    // skip salt and viewIndexId columns.
    int pkPosition = (table.getBucketNum() == null ? 0 : 1) + (table.getViewIndexId() == null ? 0 : 1);
    List<PColumn> pkColumns = table.getPKColumns();
    return new RowKeyColumnExpression(pkColumns.get(pkPosition), new RowKeyValueAccessor(pkColumns, pkPosition));
}
Also used : PColumn(org.apache.phoenix.schema.PColumn) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) RowKeyValueAccessor(org.apache.phoenix.schema.RowKeyValueAccessor) RowKeyColumnExpression(org.apache.phoenix.expression.RowKeyColumnExpression)

Example 30 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project phoenix by apache.

the class PhoenixDriverTest method testDisallowIsolationLevel.

@Ignore
@Test
public void testDisallowIsolationLevel() throws SQLException {
    Connection conn = DriverManager.getConnection(getUrl());
    conn.setTransactionIsolation(Connection.TRANSACTION_NONE);
    conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
    conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    try {
        conn = DriverManager.getConnection(getUrl());
        conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
        fail();
    } catch (SQLException e) {
        assertEquals(SQLExceptionCode.TX_MUST_BE_ENABLED_TO_SET_ISOLATION_LEVEL.getErrorCode(), e.getErrorCode());
    }
    try {
        conn = DriverManager.getConnection(getUrl());
        conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        fail();
    } catch (SQLFeatureNotSupportedException e) {
    }
    Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
    props.setProperty(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
    conn = DriverManager.getConnection(getUrl(), props);
    conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
    try {
        conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        fail();
    } catch (SQLFeatureNotSupportedException e) {
    }
}
Also used : SQLException(java.sql.SQLException) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Connection(java.sql.Connection) Properties(java.util.Properties) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Aggregations

SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)55 SQLException (java.sql.SQLException)20 Connection (java.sql.Connection)14 Test (org.testng.annotations.Test)14 BaseTest (util.BaseTest)14 PreparedStatement (java.sql.PreparedStatement)13 Statement (java.sql.Statement)11 ResultSet (java.sql.ResultSet)10 Test (org.junit.Test)5 Properties (java.util.Properties)4 CallableStatement (java.sql.CallableStatement)3 DruidPooledCallableStatement (com.alibaba.druid.pool.DruidPooledCallableStatement)2 DruidPooledResultSet (com.alibaba.druid.pool.DruidPooledResultSet)2 DruidPooledStatement (com.alibaba.druid.pool.DruidPooledStatement)2 Date (java.sql.Date)2 SQLDataException (java.sql.SQLDataException)2 Savepoint (java.sql.Savepoint)2 Vector (java.util.Vector)2 ColumnInfo (org.apache.jena.jdbc.results.metadata.columns.ColumnInfo)2 SparqlColumnInfo (org.apache.jena.jdbc.results.metadata.columns.SparqlColumnInfo)2