|
4 | 4 | SPDX-FileCopyrightText: Copyright 2003 Ryan Baldwin |
5 | 5 | SPDX-FileCopyrightText: Copyright 2005-2007 Gabriel Reid |
6 | 6 | SPDX-FileCopyrightText: Copyright 2005 Steven Jardine |
7 | | - SPDX-FileCopyrightText: Copyright 2011-2024 Mark Rotteveel |
| 7 | + SPDX-FileCopyrightText: Copyright 2011-2025 Mark Rotteveel |
8 | 8 | SPDX-FileCopyrightText: Copyright 2019 Vasiliy Yashkov |
9 | 9 | SPDX-License-Identifier: LGPL-2.1-or-later |
10 | 10 | */ |
|
22 | 22 | import org.junit.jupiter.params.provider.MethodSource; |
23 | 23 | import org.junit.jupiter.params.provider.ValueSource; |
24 | 24 |
|
| 25 | +import java.io.BufferedReader; |
25 | 26 | import java.io.ByteArrayInputStream; |
26 | 27 | import java.io.StringReader; |
27 | 28 | import java.nio.charset.StandardCharsets; |
@@ -519,7 +520,7 @@ void testUpdatableResultSet(String scrollableCursorPropertyValue) throws Excepti |
519 | 520 | counter++; |
520 | 521 | } |
521 | 522 |
|
522 | | - assertEquals(counter - 1, recordCount, "Should process " + recordCount + " rows"); |
| 523 | + assertEquals(recordCount, counter - 1, "Should process " + recordCount + " rows"); |
523 | 524 |
|
524 | 525 | // check the insertRow() feature |
525 | 526 | int newId = recordCount + 1; |
@@ -1437,6 +1438,7 @@ void testRequiringMultipleFetches() throws Exception { |
1437 | 1438 | */ |
1438 | 1439 | @ParameterizedTest |
1439 | 1440 | @MethodSource |
| 1441 | + @SuppressWarnings("MagicConstant") |
1440 | 1442 | void testIsBeforeFirst_isAfterLast_emptyResultSet_bug807(int resultSetType, int resultSetConcurrency, |
1441 | 1443 | String scrollableCursorPropertyValue) throws SQLException { |
1442 | 1444 | try (var connection = createConnection(scrollableCursorPropertyValue)) { |
@@ -1485,6 +1487,7 @@ void testNextAfterLastRowShouldNotCloseResultSet(boolean autoCommit) throws Exce |
1485 | 1487 |
|
1486 | 1488 | @ParameterizedTest |
1487 | 1489 | @MethodSource |
| 1490 | + @SuppressWarnings("MagicConstant") |
1488 | 1491 | void wasNull_onInsertRow(int resultSetType, String scrollableCursorPropertyValue) throws Exception { |
1489 | 1492 | try (var connection = createConnection(scrollableCursorPropertyValue)) { |
1490 | 1493 | executeCreateTable(connection, CREATE_TABLE_STATEMENT); |
@@ -1793,6 +1796,37 @@ void updateObject_String_InputStream_type_scaleOrLength() throws SQLException { |
1793 | 1796 | } |
1794 | 1797 | } |
1795 | 1798 |
|
| 1799 | + @Test |
| 1800 | + void clobRemainsOpenAfterNext() throws Exception { |
| 1801 | + try (var connection = getConnectionViaDriverManager()) { |
| 1802 | + executeCreateTable(connection, CREATE_TABLE_STATEMENT); |
| 1803 | + connection.setAutoCommit(false); |
| 1804 | + createTestData(2, i -> "clob-value-" + i, connection, "blob_str"); |
| 1805 | + connection.commit(); |
| 1806 | + |
| 1807 | + Clob secondClob; |
| 1808 | + |
| 1809 | + try (var stmt = connection.createStatement()) { |
| 1810 | + var rs = stmt.executeQuery("select id, blob_str from test_table order by id"); |
| 1811 | + assertNextRow(rs); |
| 1812 | + Clob firstClob = rs.getClob(2); |
| 1813 | + assertNextRow(rs); |
| 1814 | + try (BufferedReader firstReader = new BufferedReader( |
| 1815 | + assertDoesNotThrow(() -> firstClob.getCharacterStream(), |
| 1816 | + "should be able to get character stream from clob after next"))) { |
| 1817 | + assertEquals("clob-value-1", firstReader.readLine()); |
| 1818 | + } |
| 1819 | + secondClob = rs.getClob(2); |
| 1820 | + assertNoNextRow(rs); |
| 1821 | + } |
| 1822 | + try (BufferedReader secondReader = new BufferedReader( |
| 1823 | + assertDoesNotThrow(() -> secondClob.getCharacterStream(), |
| 1824 | + "should be able to get character stream from clob after statement close"))) { |
| 1825 | + assertEquals("clob-value-2", secondReader.readLine()); |
| 1826 | + } |
| 1827 | + } |
| 1828 | + } |
| 1829 | + |
1796 | 1830 | static Stream<String> scrollableCursorPropertyValues() { |
1797 | 1831 | // We are unconditionally emitting SERVER, to check if the value behaves appropriately on versions that do |
1798 | 1832 | // not support server-side scrollable cursors |
|
0 commit comments