本文整理匯總了Java中java.sql.SQLFeatureNotSupportedException類的典型用法代碼示例。如果您正苦於以下問題:Java SQLFeatureNotSupportedException類的具體用法?Java SQLFeatureNotSupportedException怎麽用?Java SQLFeatureNotSupportedException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SQLFeatureNotSupportedException類屬於java.sql包,在下文中一共展示了SQLFeatureNotSupportedException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setQueryTimeout
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public void setQueryTimeout( int milliseconds )
throws SQLException {
throwIfClosed();
if ( milliseconds < 0 ) {
throw new InvalidParameterSqlException(
"Invalid (negative) \"milliseconds\" parameter to setQueryTimeout(...)"
+ " (" + milliseconds + ")" );
}
else {
if ( 0 != milliseconds ) {
throw new SQLFeatureNotSupportedException(
"Setting network timeout is not supported." );
}
}
}
示例2: lessThanOrEqualTest
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Test
public void lessThanOrEqualTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
int someAge = 25;
SearchHits response = query(String.format("SELECT * FROM %s WHERE age <= %s LIMIT 1000", TEST_INDEX, someAge));
SearchHit[] hits = response.getHits();
boolean isEqualFound = false;
for(SearchHit hit : hits) {
int age = (int) hit.getSource().get("age");
assertThat(age, lessThanOrEqualTo(someAge));
if(age == someAge)
isEqualFound = true;
}
Assert.assertTrue(String.format("at least one of the documents need to contains age equal to %s", someAge), isEqualFound);
}
示例3: testParamSettingWhenUnsupportedTypeSaysUnsupported
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
/** Tests that "not supported" has priority over possible "type not supported"
* check. */
@Test( expected = SQLFeatureNotSupportedException.class )
public void testParamSettingWhenUnsupportedTypeSaysUnsupported() throws SQLException {
PreparedStatement prepStmt = connection.prepareStatement( "VALUES 1" );
try {
prepStmt.setClob( 2, (Clob) null );
}
catch ( final SQLFeatureNotSupportedException e ) {
assertThat(
"Check whether params.-unsupported wording changed or checks changed.",
e.toString(), PARAMETERS_NOT_SUPPORTED_MSG_MATCHER );
throw e;
}
}
示例4: othersUpdatesAreVisible
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public boolean othersUpdatesAreVisible(int type) throws SQLException {
throwIfClosed();
try {
return super.othersUpdatesAreVisible(type);
}
catch (RuntimeException e) {
if ("todo: implement this method".equals(e.getMessage())) {
throw new SQLFeatureNotSupportedException(
"othersUpdatesAreVisible(int) is not supported", e);
}
else {
throw new SQLException(e.getMessage(), e);
}
}
}
示例5: setNetworkTimeout
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public void setNetworkTimeout( Executor executor, int milliseconds )
throws AlreadyClosedSqlException,
JdbcApiSqlException,
SQLFeatureNotSupportedException {
checkNotClosed();
if ( null == executor ) {
throw new InvalidParameterSqlException(
"Invalid (null) \"executor\" parameter to setNetworkTimeout(...)" );
}
else if ( milliseconds < 0 ) {
throw new InvalidParameterSqlException(
"Invalid (negative) \"milliseconds\" parameter to setNetworkTimeout(...)"
+ " (" + milliseconds + ")" );
}
else {
if ( 0 != milliseconds ) {
throw new SQLFeatureNotSupportedException(
"Setting network timeout is not supported." );
}
}
}
示例6: topHitTest_WithInclude
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Test
public void topHitTest_WithInclude() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
Aggregations result = query(String.format("select topHits('size'=3,age='desc',include=age) from %s/account group by gender ", TEST_INDEX));
List<Terms.Bucket> buckets = ((Terms) (result.asList().get(0))).getBuckets();
for (Terms.Bucket bucket : buckets){
InternalSearchHits hits = (InternalSearchHits) ((InternalTopHits) bucket.getAggregations().asList().get(0)).getHits();
for(SearchHit hit: hits ){
Set<String> fields = hit.sourceAsMap().keySet();
Assert.assertEquals(1,fields.size());
Assert.assertEquals("age",fields.toArray()[0]);
}
}
}
示例7: getResultSetType
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public int getResultSetType() throws SQLException {
throwIfClosed();
try {
return super.getResultSetType();
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例8: updateBlob
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public void updateBlob( String columnLabel, Blob x ) throws SQLException {
throwIfClosed();
try {
super.updateBlob( columnLabel, x );
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例9: updateNCharacterStream
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public void updateNCharacterStream( int columnIndex, Reader x,
long length ) throws SQLException {
throwIfClosed();
try {
super.updateNCharacterStream( columnIndex, x, length );
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例10: doTranslate
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@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;
}
示例11: updateClob
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public void updateClob( String columnLabel, Reader reader,
long length ) throws SQLException {
throwIfClosed();
try {
super.updateClob( columnLabel, reader, length );
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例12: executeUpdate
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public int executeUpdate( String sql, String[] columnNames ) throws SQLException {
throwIfClosed();
try {
return super.executeUpdate( sql, columnNames );
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例13: statsTest
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Test
public void statsTest() throws IOException, SqlParseException, SQLFeatureNotSupportedException {
Aggregations result = query(String.format("SELECT STATS(age) FROM %s/account", TEST_INDEX));
Stats stats = result.get("STATS(age)");
Assert.assertEquals(1000, stats.getCount());
assertThat(stats.getSum(), equalTo(30171.0));
assertThat(stats.getMin(), equalTo(20.0));
assertThat(stats.getMax(), equalTo(40.0));
assertThat(stats.getAvg(), equalTo(30.171));
}
示例14: updateNClob
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
@Override
public void updateNClob( String columnLabel, Reader reader ) throws SQLException {
throwIfClosed();
try {
super.updateNClob( columnLabel, reader );
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例15: testSetQueryTimeoutRejectsTimeoutRequest
import java.sql.SQLFeatureNotSupportedException; //導入依賴的package包/類
/** Tests that setQueryTimeout(...) rejects setting a timeout. */
@Test( expected = SQLFeatureNotSupportedException.class )
public void testSetQueryTimeoutRejectsTimeoutRequest() throws SQLException {
try {
statement.setQueryTimeout( 1_000 );
}
catch ( SQLFeatureNotSupportedException e ) {
// Check exception for some mention of query timeout:
assertThat( e.getMessage(), anyOf( containsString( "Timeout" ),
containsString( "timeout" ) ) );
throw e;
}
}