Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1491028 : Snowflake JDBC Driver 4.2 compliant issue. #1857

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,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 @@ -1559,4 +1560,20 @@ 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));
}
}
}
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
Loading