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);
}
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()));
}
}
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();
}
}
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;
}
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;
}
Aggregations