|
16 | 16 | import java.sql.NClob; |
17 | 17 | import java.sql.Ref; |
18 | 18 | import java.sql.ResultSet; |
| 19 | +import java.sql.ResultSetMetaData; |
19 | 20 | import java.sql.SQLException; |
20 | 21 | import java.sql.SQLFeatureNotSupportedException; |
| 22 | +import java.sql.SQLType; |
21 | 23 | import java.sql.Statement; |
22 | 24 | import java.sql.Time; |
23 | 25 | import java.sql.Timestamp; |
@@ -192,6 +194,7 @@ public void testUnsupportedOperations() throws Throwable { |
192 | 194 | () -> rs.rowDeleted(), |
193 | 195 | () -> rs.rowInserted(), |
194 | 196 | () -> rs.rowUpdated(), |
| 197 | + () -> rs.getCursorName(), |
195 | 198 | }; |
196 | 199 |
|
197 | 200 | for (Assert.ThrowingRunnable op : rsUnsupportedMethods) { |
@@ -266,6 +269,7 @@ public void testFetchDirectionsAndSize() throws SQLException { |
266 | 269 | public void testConstants() throws SQLException { |
267 | 270 | try (Connection conn = getJdbcConnection(); Statement stmt = conn.createStatement()) { |
268 | 271 | try (ResultSet rs = stmt.executeQuery("select number from system.numbers LIMIT 2")) { |
| 272 | + Assert.assertSame(rs.getStatement(), stmt); |
269 | 273 | Assert.assertEquals(rs.getType(), ResultSet.TYPE_FORWARD_ONLY); |
270 | 274 | Assert.assertEquals(rs.getConcurrency(), ResultSet.CONCUR_READ_ONLY); |
271 | 275 | Assert.assertEquals(rs.getHoldability(), ResultSet.HOLD_CURSORS_OVER_COMMIT); |
@@ -324,4 +328,22 @@ public void testWasNull() throws SQLException { |
324 | 328 | } |
325 | 329 | } |
326 | 330 | } |
| 331 | + |
| 332 | + @Test(groups = {"integration"}) |
| 333 | + public void testGetMetadata() throws SQLException { |
| 334 | + try (Connection conn = getJdbcConnection(); Statement stmt = conn.createStatement()) { |
| 335 | + try (ResultSet rs = stmt.executeQuery("select '1'::Int32 as v1, 'test' as v2 ")) { |
| 336 | + |
| 337 | + int v1ColumnIndex = rs.findColumn("v1"); |
| 338 | + int v2ColumnIndex = rs.findColumn("v2"); |
| 339 | + |
| 340 | + ResultSetMetaData metaData = rs.getMetaData(); |
| 341 | + Assert.assertEquals(metaData.getColumnCount(), 2); |
| 342 | + Assert.assertEquals(metaData.getColumnType(1), Types.INTEGER); |
| 343 | + Assert.assertEquals(metaData.getColumnType(2), Types.VARCHAR); |
| 344 | + Assert.assertEquals(metaData.getColumnTypeName(1), "Int32"); |
| 345 | + Assert.assertEquals(metaData.getColumnTypeName(2), "String"); |
| 346 | + } |
| 347 | + } |
| 348 | + } |
327 | 349 | } |
0 commit comments