Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[CONJ-316] Wrong Exception thrown for ScrollType TYPE_SCROLL_INSENSITIVE
- Loading branch information
Showing
5 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package org.mariadb.jdbc; | ||
|
|
||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| import java.sql.PreparedStatement; | ||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
| import java.sql.Statement; | ||
|
|
||
| import static org.junit.Assert.fail; | ||
|
|
||
| public class ScrollTypeTest extends BaseTest { | ||
|
|
||
| @BeforeClass() | ||
| public static void initClass() throws SQLException { | ||
| createTable("resultsSetReadingTest", "id int not null primary key auto_increment, test int"); | ||
| sharedConnection.createStatement().execute("INSERT INTO resultsSetReadingTest (test) values (1), (2), (3)"); | ||
| } | ||
|
|
||
| @Test | ||
| public void scrollInsensitivePrepareStmt() throws SQLException { | ||
| try (PreparedStatement stmt = sharedConnection.prepareStatement("SELECT * FROM resultsSetReadingTest", | ||
| ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { | ||
| stmt.setFetchSize(2); | ||
| try (ResultSet rs = stmt.executeQuery()) { | ||
| rs.beforeFirst(); | ||
| } catch (SQLException sqle) { | ||
| fail("beforeFirst() should work on a TYPE_SCROLL_INSENSITIVE result set"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void scrollInsensitiveStmt() throws SQLException { | ||
| try (Statement stmt = sharedConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) { | ||
| stmt.setFetchSize(2); | ||
| try (ResultSet rs = stmt.executeQuery("SELECT * FROM resultsSetReadingTest")) { | ||
| rs.beforeFirst(); | ||
| } catch (SQLException sqle) { | ||
| fail("beforeFirst() should work on a TYPE_SCROLL_INSENSITIVE result set"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test(expected = SQLException.class) | ||
| public void scrollForwardOnlyPrepareStmt() throws SQLException { | ||
| try (PreparedStatement stmt = sharedConnection.prepareStatement("SELECT * FROM resultsSetReadingTest", | ||
| ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) { | ||
| stmt.setFetchSize(2); | ||
| try (ResultSet rs = stmt.executeQuery()) { | ||
| rs.beforeFirst(); | ||
| fail("beforeFirst() shouldn't work on a TYPE_FORWARD_ONLY result set"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test(expected = SQLException.class) | ||
| public void scrollForwardOnlyStmt() throws SQLException { | ||
| try (Statement stmt = sharedConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)) { | ||
| stmt.setFetchSize(2); | ||
| try (ResultSet rs = stmt.executeQuery("SELECT * FROM resultsSetReadingTest")) { | ||
| rs.beforeFirst(); | ||
| fail("beforeFirst() shouldn't work on a TYPE_FORWARD_ONLY result set"); | ||
| } | ||
| } | ||
| } | ||
| } |
ab05206There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thanks!