Java Code Examples for java.sql.SQLFeatureNotSupportedException

The following examples show how to use java.sql.SQLFeatureNotSupportedException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: snowflake-jdbc   Source File: StatementIT.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test Autogenerated key.
 *
 * @throws Throwable if any error occurs
 */
@Test
public void testAutogenerateKey() throws Throwable
{
  try (Connection connection = getConnection())
  {
    Statement statement = connection.createStatement();
    statement.execute("create or replace table t(c1 int)");
    statement.execute("insert into t values(1)", Statement.NO_GENERATED_KEYS);
    try
    {
      statement.execute("insert into t values(2)", Statement.RETURN_GENERATED_KEYS);
      fail("no autogenerate key is supported");
    }
    catch (SQLFeatureNotSupportedException ex)
    {
      // nop
    }
    // empty result
    ResultSet rset = statement.getGeneratedKeys();
    assertFalse(rset.next());
    rset.close();
  }
}
 
Example 2
Source Project: phoenix   Source File: PhoenixRuntime.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get expression that may be used to evaluate the tenant ID of a given row in a
 * multi-tenant table. Both the SYSTEM.CATALOG table and the SYSTEM.SEQUENCE
 * table are considered multi-tenant.
 * @param conn open Phoenix connection
 * @param fullTableName full table name
 * @return An expression that may be evaluated for a row in the provided table or
 * null if the table is not a multi-tenant table. 
 * @throws SQLException if the table name is not found, a TableNotFoundException
 * is thrown. If a multi-tenant local index is supplied a SQLFeatureNotSupportedException
 * is thrown.
 */
public static Expression getTenantIdExpression(Connection conn, String fullTableName) throws SQLException {
    PTable table = getTable(conn, fullTableName);
    // TODO: consider setting MULTI_TENANT = true for SYSTEM.CATALOG and SYSTEM.SEQUENCE
    if (!SchemaUtil.isMetaTable(table) && !SchemaUtil.isSequenceTable(table) && !table.isMultiTenant()) {
        return null;
    }
    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();
    }
    
    int pkPosition = table.getBucketNum() == null ? 0 : 1;
    List<PColumn> pkColumns = table.getPKColumns();
    return new RowKeyColumnExpression(pkColumns.get(pkPosition), new RowKeyValueAccessor(pkColumns, pkPosition));
}
 
Example 3
Source Project: dremio-oss   Source File: DremioDatabaseMetaDataImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean ownUpdatesAreVisible(int type) throws SQLException {
  throwIfClosed();
  try {
    return super.ownUpdatesAreVisible(type);
  }
  catch (RuntimeException e) {
    if ("todo: implement this method".equals(e.getMessage())) {
      throw new SQLFeatureNotSupportedException(
          "ownUpdatesAreVisible(int) is not supported", e);
    }
    else {
      throw new SQLException(e.getMessage(), e);
    }
  }
}
 
Example 4
Source Project: elasticsearch-sql   Source File: QueryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void idsQueryMultipleId() throws SqlParseException, SQLFeatureNotSupportedException {
    String query = String.format("select * from %s/dog where _id = IDS_QUERY(dog,1,2,3)",TEST_INDEX_DOG);
    SearchHit[] hits = query(query).getHits();
    Assert.assertEquals(1,hits.length);
    Map<String, Object> hitAsMap = hits[0].getSourceAsMap();
    Assert.assertEquals("rex",hitAsMap.get("dog_name"));
    Assert.assertEquals("Daenerys",hitAsMap.get("holdersName"));
    Assert.assertEquals(2, hitAsMap.get("age"));

}
 
Example 5
public void testUpdateNClobStringLengthlessNotImplemented()
    throws SQLException {
    try {
        rs.updateNClob("some-column-name", (Reader)null);
        fail("ResultSet.updateNClob(String, Reader) " +
             "should not be implemented");
    } catch (SQLFeatureNotSupportedException sfnse) {
        // We are fine, do nothing.
    }
}
 
Example 6
@Test
public void testupdateNClob70() {
  try {
    rs.updateNClob(1, (java.sql.NClob) null);
  } catch (SQLFeatureNotSupportedException sqle) {
    Assert.fail();
  } catch (SQLException sqlee) {
    // eat
  }
}
 
Example 7
@Test
public void testupdateAsciiStream33() {
  try {
    rs.updateAsciiStream("a", null);
  } catch (SQLFeatureNotSupportedException sqle) {
    Assert.fail();
  } catch (SQLException sqlee) {
    // eat
  }
}
 
Example 8
Source Project: snowflake-jdbc   Source File: SnowflakeBaseResultSet.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void updateRowId(int columnIndex, RowId x) throws SQLException
{
  logger.debug(
      "public void updateRowId(int columnIndex, RowId x)");

  throw new SQLFeatureNotSupportedException();
}
 
Example 9
Source Project: dremio-oss   Source File: DremioResultSetImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void updateByte( int columnIndex, byte x ) throws SQLException {
  throwIfClosed();
  try {
    super.updateByte( columnIndex, x );
  }
  catch (UnsupportedOperationException e) {
    throw new SQLFeatureNotSupportedException(e.getMessage(), e);
  }
}
 
Example 10
@Override
@Deprecated
public void setUnicodeStream(int parameterIndex, InputStream x, int length)
throws SQLException
{
  throw new SQLFeatureNotSupportedException();
}
 
Example 11
Source Project: gemfirexd-oss   Source File: ResultSetTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testGetNClobStringNotImplemented()
    throws SQLException {
    try {
        rs.getNClob("some-column-name");
        fail("ResultSet.getNClob(String) " +
             "should not be implemented");
    } catch (SQLFeatureNotSupportedException sfnse) {
        // We are fine, do nothing.
    }
}
 
Example 12
Source Project: snowflake-jdbc   Source File: SnowflakeBaseResultSet.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean previous() throws SQLException
{
  logger.debug("public boolean previous()");

  throw new SQLFeatureNotSupportedException();
}
 
Example 13
public void testUpdateNClobStringNotImplemented()
    throws SQLException {
    try {
        rs.updateNClob("some-column-name", (NClob)null);
        fail("ResultSet.updateNClob(String, NClob) " +
             "should not be implemented");
    } catch (SQLFeatureNotSupportedException sfnse) {
        // We are fine, do nothing.
    }
}
 
Example 14
/**
 * Create SQLFeatureNotSupportedException with message, SQLState, errorCode, and Throwable
 */
@Test
public void test5() {
    SQLFeatureNotSupportedException ex =
            new SQLFeatureNotSupportedException(reason, state, errorCode, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == errorCode);
}
 
Example 15
@Override
protected DataAccessException doTranslate(String task, String sql, SQLException ex) {
	if (ex instanceof SQLTransientException) {
		if (ex instanceof SQLTransientConnectionException) {
			return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLTransactionRollbackException) {
			return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLTimeoutException) {
			return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
		}
	}
	else if (ex instanceof SQLNonTransientException) {
		if (ex instanceof SQLNonTransientConnectionException) {
			return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLDataException) {
			return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLIntegrityConstraintViolationException) {
			return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLInvalidAuthorizationSpecException) {
			return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
		}
		else if (ex instanceof SQLSyntaxErrorException) {
			return new BadSqlGrammarException(task, sql, ex);
		}
		else if (ex instanceof SQLFeatureNotSupportedException) {
			return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
		}
	}
	else if (ex instanceof SQLRecoverableException) {
		return new RecoverableDataAccessException(buildMessage(task, sql, ex), ex);
	}

	// Fallback to Spring's own SQL state translation...
	return null;
}
 
Example 16
/**
 * Create SQLFeatureNotSupportedException with message, SQLState, and Throwable
 */
@Test
public void test6() {
    SQLFeatureNotSupportedException ex =
            new SQLFeatureNotSupportedException(reason, state, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == 0);
}
 
Example 17
Source Project: elasticsearch-sql   Source File: QueryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void twoSubQueriesTest() throws SqlParseException, SQLFeatureNotSupportedException {
    String query = String.format("select * from %s/dog where holdersName IN (select firstname from %s/account where firstname = 'Hattie') and age IN (select name.ofHisName from %s/gotCharacters where name.firstname <> 'Daenerys' and name.ofHisName IS NOT NULL) ",TEST_INDEX_DOG,TEST_INDEX_ACCOUNT,TEST_INDEX_GAME_OF_THRONES);
    SearchHit[] hits = query(query).getHits();
    Assert.assertEquals(1,hits.length);
    Map<String, Object> hitAsMap = hits[0].getSourceAsMap();
    Assert.assertEquals("snoopy",hitAsMap.get("dog_name"));
    Assert.assertEquals("Hattie",hitAsMap.get("holdersName"));
    Assert.assertEquals(4,hitAsMap.get("age"));

}
 
Example 18
@Override
public void setFetchDirection(final int direction) throws SQLException {
    throw new SQLFeatureNotSupportedException("setFetchDirection");
}
 
Example 19
public String getColumnClassName(int column) throws SQLException {
    throw new SQLFeatureNotSupportedException();
}
 
Example 20
Source Project: sql4es   Source File: ESConnection.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Savepoint setSavepoint(String name) throws SQLException {
	 throw new SQLFeatureNotSupportedException(Utils.getLoggingInfo());
}
 
Example 21
Source Project: presto   Source File: PrestoResultSet.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void updateBigDecimal(int columnIndex, BigDecimal x)
        throws SQLException
{
    throw new SQLFeatureNotSupportedException("updateBigDecimal");
}
 
Example 22
Source Project: ignite   Source File: JdbcPreparedStatement.java    License: Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void setSQLXML(int paramIdx, SQLXML xmlObj) throws SQLException {
    ensureNotClosed();

    throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
}
 
Example 23
Source Project: ecosys   Source File: BaseDriver.java    License: Apache License 2.0 4 votes vote down vote up
@Override public Logger getParentLogger() throws SQLFeatureNotSupportedException {
   throw new UnsupportedOperationException("Not implemented yet.");
}
 
Example 24
Source Project: requery   Source File: BasePreparedStatement.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
    throw new SQLFeatureNotSupportedException();
}
 
Example 25
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetClobWithLabel() throws SQLException {
    databaseMetaDataResultSet.getClob("");
}
 
Example 26
Source Project: micro-integrator   Source File: TResultSet.java    License: Apache License 2.0 4 votes vote down vote up
public void updateFloat(int columnIndex, float x) throws SQLException {
    determineResultSetState();
    throw new SQLFeatureNotSupportedException("Operation not supported");
}
 
Example 27
@Test(expected = SQLFeatureNotSupportedException.class)
public void getWarnings() throws SQLException {
    new GeneratedKeysResultSet().getWarnings();
}
 
Example 28
Source Project: presto   Source File: PrestoResultSet.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void updateBinaryStream(String columnLabel, InputStream x, long length)
        throws SQLException
{
    throw new SQLFeatureNotSupportedException("updateBinaryStream");
}
 
Example 29
Source Project: jackcess   Source File: OleUtil.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public int setBytes(long pos, byte[] bytes, int offset, int lesn)
  throws SQLException {
  throw new SQLFeatureNotSupportedException();
}
 
Example 30
Source Project: ignite   Source File: JdbcThinResultSet.java    License: Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public NClob getNClob(int colIdx) throws SQLException {
    ensureNotClosed();

    throw new SQLFeatureNotSupportedException("SQL-specific types are not supported.");
}