Skip to content

Commit 70fac50

Browse files
authored
Fixed unimplemented methods in DatabricksConnection for methods which has default input by users (#912)
## Description Added a check in the parameterized createStatement function to check if the parameters match the default value before throwing the error. ## Testing - Tested Locally Related tickets: [PECOBLR-665](https://databricks.atlassian.net/browse/PECOBLR-665) NO_CHANGELOG=true [PECOBLR-665]: https://databricks.atlassian.net/browse/PECOBLR-665?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent dff82dd commit 70fac50

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/main/java/com/databricks/jdbc/api/impl/DatabricksConnection.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,13 @@ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
324324
@Override
325325
public Statement createStatement(
326326
int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
327-
328-
throw new DatabricksSQLFeatureNotImplementedException(
329-
"Not implemented in DatabricksConnection - createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)");
327+
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY
328+
|| resultSetConcurrency != ResultSet.CONCUR_READ_ONLY
329+
|| resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
330+
throw new DatabricksSQLFeatureNotImplementedException(
331+
"Databricks OSS JDBC only supports resultSetType as ResultSet.TYPE_FORWARD_ONLY, resultSetConcurrency as ResultSet.CONCUR_READ_ONLY and resultSetHoldability as ResultSet.CLOSE_CURSORS_AT_COMMIT");
332+
}
333+
return createStatement();
330334
}
331335

332336
@Override

src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,24 @@ void testUnsupportedOperations() throws SQLException {
353353
() -> connection.prepareStatement(SQL, 1, 1, 1));
354354
assertThrows(
355355
DatabricksSQLFeatureNotSupportedException.class, () -> connection.prepareStatement(SQL, 1));
356+
// Test createStatement with default values succeeds
357+
assertDoesNotThrow(
358+
() -> {
359+
connection.createStatement(
360+
ResultSet.TYPE_FORWARD_ONLY,
361+
ResultSet.CONCUR_READ_ONLY,
362+
ResultSet.CLOSE_CURSORS_AT_COMMIT);
363+
});
364+
365+
// Test createStatement with non-default values throws exception
356366
assertThrows(
357367
DatabricksSQLFeatureNotImplementedException.class,
358-
() -> connection.createStatement(1, 1, 1));
368+
() -> {
369+
connection.createStatement(
370+
ResultSet.TYPE_SCROLL_INSENSITIVE,
371+
ResultSet.CONCUR_READ_ONLY,
372+
ResultSet.CLOSE_CURSORS_AT_COMMIT);
373+
});
359374
assertThrows(
360375
DatabricksSQLFeatureNotImplementedException.class, () -> connection.setSavepoint("1"));
361376
assertThrows(DatabricksSQLFeatureNotImplementedException.class, connection::setSavepoint);

0 commit comments

Comments
 (0)