Skip to content

Commit

Permalink
SNOW-1491028 : Snowflake JDBC Driver 4.2 compliant issue. (#1857)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-vb authored Aug 29, 2024
1 parent a6c926d commit 74dbd19
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,16 @@ public int getHoldability() throws SQLException {
@Override
public void setHoldability(int holdability) throws SQLException {

throw new SnowflakeLoggedFeatureNotSupportedException(sfSession);
raiseSQLExceptionIfConnectionIsClosed();
if ((holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT
&& holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT)) {
throw new SQLException("The given parameter is not a ResultSet holdability constant.");
}
// HOLD_CURSORS_OVER_COMMIT holdability is currently not supported.
// no-op if the holdability is CLOSE_CURSORS_AT_COMMIT
if (holdability == ResultSet.HOLD_CURSORS_OVER_COMMIT) {
throw new SnowflakeLoggedFeatureNotSupportedException(sfSession);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public void testFeatureNotSupportedException() throws Throwable {
expectFeatureNotSupportedException(connection::createSQLXML);
expectFeatureNotSupportedException(
() -> connection.createStruct("fakeType", new Object[] {}));
expectFeatureNotSupportedException(
() -> connection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/snowflake/client/jdbc/ConnectionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ public void testGetTypeMap() throws Throwable {
public void testHolderbility() throws Throwable {
try (Connection connection = getConnection()) {
try {
connection.setHoldability(0);
connection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
} catch (SQLFeatureNotSupportedException ex) {
// nop
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Statement;
import java.time.Duration;
import java.util.ArrayList;
Expand Down Expand Up @@ -1589,6 +1590,22 @@ public void shouldGetDifferentTimestampLtzConsistentBetweenFormats() throws Exce
}
}

@Test
public void testSetHoldability() throws Throwable {
try (Connection connection = getConnection()) {
try {
connection.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
} catch (SQLFeatureNotSupportedException ex) {
fail("should not fail");
}
// return an empty type map. setTypeMap is not supported.
assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, connection.getHoldability());
connection.close();
expectConnectionAlreadyClosedException(
() -> connection.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT));
}
}

/** Added in > 3.14.5 and modified in > 3.18.0 */
@Test
public void shouldGetOverridenConnectionAndSocketTimeouts() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public void testLogicalConnectionFeatureNotSupported() throws SQLException {
expectFeatureNotSupportedException(logicalConnection::createBlob);
expectFeatureNotSupportedException(logicalConnection::createNClob);
expectFeatureNotSupportedException(logicalConnection::createSQLXML);
expectFeatureNotSupportedException(
() -> logicalConnection.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT));
expectFeatureNotSupportedException(
() -> logicalConnection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT));
expectFeatureNotSupportedException(
Expand Down

0 comments on commit 74dbd19

Please sign in to comment.