use of java.sql.SQLFeatureNotSupportedException in project calcite-avatica by apache.
the class JdbcResultSet method getValue.
private static Object getValue(ResultSet resultSet, int type, int j, Calendar calendar) throws SQLException {
switch(type) {
case Types.BIGINT:
final long aLong = resultSet.getLong(j + 1);
return aLong == 0 && resultSet.wasNull() ? null : aLong;
case Types.INTEGER:
final int anInt = resultSet.getInt(j + 1);
return anInt == 0 && resultSet.wasNull() ? null : anInt;
case Types.SMALLINT:
final short aShort = resultSet.getShort(j + 1);
return aShort == 0 && resultSet.wasNull() ? null : aShort;
case Types.TINYINT:
final byte aByte = resultSet.getByte(j + 1);
return aByte == 0 && resultSet.wasNull() ? null : aByte;
case Types.DOUBLE:
case Types.FLOAT:
final double aDouble = resultSet.getDouble(j + 1);
return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
case Types.REAL:
final float aFloat = resultSet.getFloat(j + 1);
return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
case Types.DATE:
final Date aDate = resultSet.getDate(j + 1, calendar);
return aDate == null ? null : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY);
case Types.TIME:
final Time aTime = resultSet.getTime(j + 1, calendar);
return aTime == null ? null : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY);
case Types.TIMESTAMP:
final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar);
return aTimestamp == null ? null : aTimestamp.getTime();
case Types.ARRAY:
final Array array = resultSet.getArray(j + 1);
if (null == array) {
return null;
}
try {
// Recursively extracts an Array using its ResultSet-representation
return extractUsingResultSet(array, calendar);
} catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
// assumes a non-nested array (depends on the db if that's a valid assumption)
return extractUsingArray(array, calendar);
}
case Types.STRUCT:
Struct struct = resultSet.getObject(j + 1, Struct.class);
Object[] attrs = struct.getAttributes();
List<Object> list = new ArrayList<>(attrs.length);
for (Object o : attrs) {
list.add(o);
}
return list;
default:
return resultSet.getObject(j + 1);
}
}
use of java.sql.SQLFeatureNotSupportedException in project phoenix by apache.
the class SQLParser method nextStatement.
/**
* Parses the input as a series of semicolon-terminated SQL statements.
* @throws SQLException
*/
public BindableStatement nextStatement(ParseNodeFactory factory) throws SQLException {
try {
parser.resetBindCount();
parser.setParseNodeFactory(factory);
BindableStatement statement = parser.nextStatement();
return statement;
} catch (RecognitionException e) {
throw PhoenixParserException.newException(e, parser.getTokenNames());
} catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e);
} catch (RuntimeException e) {
if (e.getCause() instanceof SQLException) {
throw (SQLException) e.getCause();
}
throw PhoenixParserException.newException(e, parser.getTokenNames());
}
}
use of java.sql.SQLFeatureNotSupportedException in project spanner-jdbc by olavloite.
the class CloudSpannerConnectionPoolDataSourceTest method createDataSourceTest.
@Test
public void createDataSourceTest() throws SQLException {
CloudSpannerConnectionPoolDataSource subject = new CloudSpannerConnectionPoolDataSource();
subject.setProjectId("helpful-adroit-123456");
subject.setInstanceId("test-instance");
subject.setDatabase("test");
subject.setPvtKeyPath("C:\\Users\\MyUserName\\Documents\\CloudSpannerKeys\\cloudspanner-key.json");
subject.setPvtKeyPath(null);
subject.setOauthAccessToken("TEST");
subject.setSimulateProductName("PostgreSQL");
subject.setAllowExtendedMode(true);
subject.setLoginTimeout(10);
subject.setDefaultAutoCommit(false);
subject.setLogWriter(new PrintWriter(System.out));
Assert.assertEquals("ConnectionPoolDataSource from " + nl.topicus.jdbc.CloudSpannerDriver.getVersion(), subject.getDescription());
PooledConnection con = subject.getPooledConnection();
Assert.assertNotNull(con);
ICloudSpannerConnection connection = (ICloudSpannerConnection) con.getConnection();
Assert.assertEquals("jdbc:cloudspanner://localhost", connection.getUrl());
Assert.assertEquals("PostgreSQL", connection.getProductName());
Assert.assertEquals("helpful-adroit-123456", connection.getSuppliedProperties().getProperty("Project"));
Assert.assertEquals("test-instance", connection.getSuppliedProperties().getProperty("Instance"));
Assert.assertEquals("test", connection.getSuppliedProperties().getProperty("Database"));
Assert.assertEquals("TEST", connection.getSuppliedProperties().getProperty("OAuthAccessToken"));
Assert.assertTrue(connection.isAllowExtendedMode());
Assert.assertEquals(subject.isDefaultAutoCommit(), connection.getAutoCommit());
PooledConnection con2 = subject.getPooledConnection("TEST", "TEST");
Assert.assertNotNull(con2);
boolean exception = false;
try {
subject.getParentLogger();
} catch (SQLFeatureNotSupportedException e) {
exception = true;
}
Assert.assertTrue(exception);
}
Aggregations