java.sql.SQLFeatureNotSupportedException Java Examples

The following examples show how to use java.sql.SQLFeatureNotSupportedException. 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   Author: snowflakedb   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   Author: cloudera-labs   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   Author: dremio   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   Author: NLPchina   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
Source Project: spliceengine   Author: splicemachine   File: ResultSetTest.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
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
Source Project: mariadb-connector-j   Author: mariadb-corporation   File: UpdateResultSetMethodsTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testupdateNClob70() {
  try {
    rs.updateNClob(1, (java.sql.NClob) null);
  } catch (SQLFeatureNotSupportedException sqle) {
    Assert.fail();
  } catch (SQLException sqlee) {
    // eat
  }
}
 
Example #7
Source Project: mariadb-connector-j   Author: mariadb-corporation   File: UpdateResultSetMethodsTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testupdateAsciiStream33() {
  try {
    rs.updateAsciiStream("a", null);
  } catch (SQLFeatureNotSupportedException sqle) {
    Assert.fail();
  } catch (SQLException sqlee) {
    // eat
  }
}
 
Example #8
Source Project: snowflake-jdbc   Author: snowflakedb   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   Author: dremio   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
Source Project: snowflake-jdbc   Author: snowflakedb   File: SnowflakePreparedStatementV1.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public void setUnicodeStream(int parameterIndex, InputStream x, int length)
throws SQLException
{
  throw new SQLFeatureNotSupportedException();
}
 
Example #11
Source Project: gemfirexd-oss   Author: gemxd   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   Author: snowflakedb   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
Source Project: spliceengine   Author: splicemachine   File: ResultSetTest.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
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
Source Project: jdk8u_jdk   Author: JetBrains   File: SQLFeatureNotSupportedExceptionTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source Project: lams   Author: lamsfoundation   File: SQLExceptionSubclassTranslator.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: SQLFeatureNotSupportedExceptionTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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   Author: NLPchina   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
Source Project: sharding-jdbc-1.5.1   Author: tianheframe   File: AbstractUnsupportedGeneratedKeysResultSet.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setFetchDirection(final int direction) throws SQLException {
    throw new SQLFeatureNotSupportedException("setFetchDirection");
}
 
Example #19
Source Project: fabric-jdbc-connector   Author: Impetus   File: FabricResultSetMetaData.java    License: Apache License 2.0 4 votes vote down vote up
public String getColumnClassName(int column) throws SQLException {
    throw new SQLFeatureNotSupportedException();
}
 
Example #20
Source Project: sql4es   Author: Anchormen   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   Author: prestosql   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   Author: apache   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   Author: tigergraph   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   Author: requery   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
Source Project: shardingsphere   Author: apache   File: UnSupportedDatabaseMetaDataResultSetTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetClobWithLabel() throws SQLException {
    databaseMetaDataResultSet.getClob("");
}
 
Example #26
Source Project: micro-integrator   Author: wso2   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
Source Project: sharding-jdbc-1.5.1   Author: tianheframe   File: UnsupportedGeneratedKeysResultSetTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = SQLFeatureNotSupportedException.class)
public void getWarnings() throws SQLException {
    new GeneratedKeysResultSet().getWarnings();
}
 
Example #28
Source Project: presto   Author: prestosql   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   Author: jahlborn   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   Author: apache   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.");
}