Search in sources :

Example 21 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project jdk8u_jdk by JetBrains.

the class SQLFeatureNotSupportedExceptionTests method test4.

/**
     * Create SQLFeatureNotSupportedException with message, SQLState, and error code
     */
@Test
public void test4() {
    SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException(reason, state, errorCode);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState().equals(state) && ex.getCause() == null && ex.getErrorCode() == errorCode);
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 22 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project jdk8u_jdk by JetBrains.

the class SQLFeatureNotSupportedExceptionTests method test11.

/**
     * Validate that the ordering of the returned Exceptions is correct
     * using for-each loop
     */
@Test
public void test11() {
    SQLFeatureNotSupportedException ex = new SQLFeatureNotSupportedException("Exception 1", t1);
    SQLFeatureNotSupportedException ex1 = new SQLFeatureNotSupportedException("Exception 2");
    SQLFeatureNotSupportedException ex2 = new SQLFeatureNotSupportedException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 23 with SQLFeatureNotSupportedException

use of java.sql.SQLFeatureNotSupportedException in project calcite-avatica by apache.

the class InsertTest method batchInsert.

@Test
public void batchInsert() throws Exception {
    final String tableName = getTableName();
    try (Statement stmt = connection.createStatement()) {
        assertFalse(stmt.execute("DROP TABLE IF EXISTS " + tableName));
        String sql = "CREATE TABLE " + tableName + " (pk integer not null primary key, col1 varchar(10))";
        assertFalse(stmt.execute(sql));
        for (int i = 0; i < 10; i++) {
            sql = "INSERT INTO " + tableName + " values (" + i + ", '" + i + "')";
            try {
                stmt.addBatch(sql);
            } catch (SQLFeatureNotSupportedException e) {
                // batch isn't supported in this version, gracefully ignore,
                Assume.assumeTrue("Batch update is not support by the client", false);
            }
        }
        int[] updateCounts = stmt.executeBatch();
        int[] expectedUpdateCounts = new int[10];
        Arrays.fill(expectedUpdateCounts, 1);
        assertArrayEquals(expectedUpdateCounts, updateCounts);
        ResultSet results = stmt.executeQuery("SELECT * FROM " + tableName);
        assertNotNull(results);
        for (int i = 0; i < 10; i++) {
            assertTrue(results.next());
            assertEquals(i, results.getInt(1));
            assertEquals(Integer.toString(i), results.getString(1));
        }
        assertFalse(results.next());
        results.close();
    }
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) ResultSet(java.sql.ResultSet) Test(org.junit.Test)

Example 24 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 (resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
        throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
    JdbcStatement stmt = new JdbcStatement(this);
    if (timeout > 0)
        stmt.timeout(timeout);
    return stmt;
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException)

Example 25 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 (resSetHoldability != HOLD_CURSORS_OVER_COMMIT)
        throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported).");
    JdbcPreparedStatement stmt = new JdbcPreparedStatement(this, sql);
    if (timeout > 0)
        stmt.timeout(timeout);
    return stmt;
}
Also used : SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException)

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