Skip to content

Commit 3b1a594

Browse files
author
Paultagoras
committed
Resolving some issues
1 parent 36cad37 commit 3b1a594

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/JdbcV2Wrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ default boolean isWrapperFor(Class<?> iface) throws SQLException {
1111
@SuppressWarnings("unchecked")
1212
default <T> T unwrap(Class<T> iface) throws SQLException {
1313
if (isWrapperFor(iface)) {
14-
iface.cast(this);
14+
return iface.cast(this);
1515
}
1616
throw new SQLException("Cannot unwrap to " + iface.getName());
1717
}

jdbc-v2/src/main/java/com/clickhouse/jdbc/ResultSetImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ public TableSchema getSchema() {
5757
public boolean next() throws SQLException {
5858
checkClosed();
5959

60-
Map<String, Object> currentRow = reader.next();
61-
return currentRow != null;
60+
try {
61+
Map<String, Object> currentRow = reader.next();
62+
return currentRow != null;
63+
} catch (Exception e) {
64+
throw ExceptionUtils.toSqlState(e);
65+
}
6266
}
6367

6468
@Override

jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public void setShardingKeyTest() throws SQLException {
308308
assertThrows(SQLFeatureNotSupportedException.class, () -> localConnection.setShardingKey(null, null));
309309
}
310310

311-
@Test
311+
@Test(groups = { "integration" })
312312
public void testMaxResultRowsProperty() throws Exception {
313313
Properties properties = new Properties();
314314
properties.setProperty(Driver.chSettingKey(ServerSettings.MAX_RESULT_ROWS), "5");
@@ -323,7 +323,7 @@ public void testMaxResultRowsProperty() throws Exception {
323323
}
324324
}
325325

326-
@Test
326+
@Test(groups = { "integration" })
327327
public void testSecureConnection() throws Exception {
328328
if (isCloud()) {
329329
return; // this test uses self-signed cert
@@ -357,7 +357,7 @@ public void testSecureConnection() throws Exception {
357357
}
358358
}
359359

360-
@Test
360+
@Test(groups = { "integration" })
361361
public void testSelectingDatabase() throws Exception {
362362
ClickHouseNode server = getServer(ClickHouseProtocol.HTTP);
363363
Properties properties = new Properties();
@@ -394,4 +394,14 @@ public void testSelectingDatabase() throws Exception {
394394
Assert.assertEquals(rs.getString(1), "system");
395395
}
396396
}
397+
398+
@Test(groups = { "integration" })
399+
public void testUnwrapping() throws Exception {
400+
Connection conn = getJdbcConnection();
401+
Assert.assertTrue(conn.isWrapperFor(Connection.class));
402+
Assert.assertTrue(conn.isWrapperFor(JdbcV2Wrapper.class));
403+
Assert.assertEquals(conn.unwrap(Connection.class), conn);
404+
Assert.assertEquals(conn.unwrap(JdbcV2Wrapper.class), conn);
405+
assertThrows(SQLException.class, () -> conn.unwrap(ResultSet.class));
406+
}
397407
}

0 commit comments

Comments
 (0)