Skip to content

Commit 8408fdd

Browse files
committed
added creating result set from array
1 parent a320a07 commit 8408fdd

File tree

1 file changed

+9
-3
lines changed
  • jdbc-v2/src/main/java/com/clickhouse/jdbc/types

1 file changed

+9
-3
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/types/Array.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Array implements java.sql.Array {
2222
private final String elementTypeName;
2323
private boolean valid;
2424
private final ClickHouseDataType baseDataType;
25+
private ArrayResultSet arrayResultSet;
2526

2627
public Array(ClickHouseColumn column, Object[] elements) throws SQLException {
2728
this.column = column;
@@ -88,8 +89,12 @@ public Object getArray(long index, int count, Map<String, Class<?>> map) throws
8889
}
8990

9091
@Override
91-
public ResultSet getResultSet() throws SQLException {
92-
throw new SQLFeatureNotSupportedException("getResultSet() is not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
92+
public synchronized ResultSet getResultSet() throws SQLException {
93+
ensureValid();
94+
if (arrayResultSet == null) {
95+
arrayResultSet = new ArrayResultSet(array, column);
96+
}
97+
return arrayResultSet;
9398
}
9499

95100
@Override
@@ -99,7 +104,8 @@ public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
99104

100105
@Override
101106
public ResultSet getResultSet(long index, int count) throws SQLException {
102-
throw new SQLFeatureNotSupportedException("getResultSet(long, int) is not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
107+
ensureValid();
108+
return new ArrayResultSet(getArray(index, count), column);
103109
}
104110

105111
@Override

0 commit comments

Comments
 (0)