类java.sql.SQLFeatureNotSupportedException源码实例Demo

下面列出了怎么用java.sql.SQLFeatureNotSupportedException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: snowflake-jdbc   文件: StatementIT.java
/**
 * 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();
  }
}
 
源代码2 项目: phoenix   文件: PhoenixRuntime.java
/**
 * 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));
}
 
源代码3 项目: dremio-oss   文件: DremioDatabaseMetaDataImpl.java
@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);
    }
  }
}
 
源代码4 项目: elasticsearch-sql   文件: QueryTest.java
@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"));

}
 
源代码5 项目: spliceengine   文件: ResultSetTest.java
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.
    }
}
 
@Test
public void testupdateNClob70() {
  try {
    rs.updateNClob(1, (java.sql.NClob) null);
  } catch (SQLFeatureNotSupportedException sqle) {
    Assert.fail();
  } catch (SQLException sqlee) {
    // eat
  }
}
 
@Test
public void testupdateAsciiStream33() {
  try {
    rs.updateAsciiStream("a", null);
  } catch (SQLFeatureNotSupportedException sqle) {
    Assert.fail();
  } catch (SQLException sqlee) {
    // eat
  }
}
 
源代码8 项目: snowflake-jdbc   文件: SnowflakeBaseResultSet.java
@Override
public void updateRowId(int columnIndex, RowId x) throws SQLException
{
  logger.debug(
      "public void updateRowId(int columnIndex, RowId x)");

  throw new SQLFeatureNotSupportedException();
}
 
源代码9 项目: dremio-oss   文件: DremioResultSetImpl.java
@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);
  }
}
 
@Override
@Deprecated
public void setUnicodeStream(int parameterIndex, InputStream x, int length)
throws SQLException
{
  throw new SQLFeatureNotSupportedException();
}
 
源代码11 项目: gemfirexd-oss   文件: ResultSetTest.java
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.
    }
}
 
源代码12 项目: snowflake-jdbc   文件: SnowflakeBaseResultSet.java
@Override
public boolean previous() throws SQLException
{
  logger.debug("public boolean previous()");

  throw new SQLFeatureNotSupportedException();
}
 
源代码13 项目: spliceengine   文件: ResultSetTest.java
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.
    }
}
 
/**
 * 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);
}
 
源代码15 项目: lams   文件: SQLExceptionSubclassTranslator.java
@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;
}
 
/**
 * 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);
}
 
源代码17 项目: elasticsearch-sql   文件: QueryTest.java
@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"));

}
 
@Override
public void setFetchDirection(final int direction) throws SQLException {
    throw new SQLFeatureNotSupportedException("setFetchDirection");
}
 
public String getColumnClassName(int column) throws SQLException {
    throw new SQLFeatureNotSupportedException();
}
 
源代码20 项目: sql4es   文件: ESConnection.java
@Override
public Savepoint setSavepoint(String name) throws SQLException {
	 throw new SQLFeatureNotSupportedException(Utils.getLoggingInfo());
}
 
源代码21 项目: presto   文件: PrestoResultSet.java
@Override
public void updateBigDecimal(int columnIndex, BigDecimal x)
        throws SQLException
{
    throw new SQLFeatureNotSupportedException("updateBigDecimal");
}
 
源代码22 项目: ignite   文件: JdbcPreparedStatement.java
/** {@inheritDoc} */
@Override public void setSQLXML(int paramIdx, SQLXML xmlObj) throws SQLException {
    ensureNotClosed();

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

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