Skip to content

Allow deactivating autocommit for AbstractImmediateDatabaseObjectWriter #136

@kaklakariada

Description

@kaklakariada

Method AbstractImmediateDatabaseObjectWriter.write(Table, Stream<List<Object>>) inserts rows into a table. This methods sets autocommit to false to insert all rows in a single transactions. Some JDBC drivers like Databricks don't support setting autocommit and fail with the following exception:

com.exasol.dbbuilder.dialects.DatabaseObjectException: E-TDBJ-2: Failed to create prepared statement 'INSERT INTO `db-vs-test-1724303193898`.`db-vs-test-schema-1724303193898`.`tab` VALUES(?)' for insert. In the context of table `db-vs-test-1724303193898`.`db-vs-test-schema-1724303193898`.`tab`
 at com.exasol.dbbuilder.dialects.AbstractImmediateDatabaseObjectWriter.write(AbstractImmediateDatabaseObjectWriter.java:99)
 at com.exasol.dbbuilder.dialects.Table.bulkInsert(Table.java:98)
 at com.exasol.dbbuilder.dialects.Table.insert(Table.java:76)
 at com.exasol.adapter.databricks.DatabricksSetupTest.createCatalog(DatabricksSetupTest.java:25)
 at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
 at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.sql.SQLFeatureNotSupportedException: [Databricks][JDBC](10220) Driver does not support this optional feature.
 at com.databricks.client.exceptions.ExceptionConverter.toSQLException(Unknown Source)
 at com.databricks.client.jdbc.common.SConnection.setAutoCommit(Unknown Source)
 at com.databricks.client.jdbc.jdbc42.DSS42Connection.setAutoCommit(Unknown Source)
 at com.exasol.dbbuilder.dialects.AbstractImmediateDatabaseObjectWriter.write(AbstractImmediateDatabaseObjectWriter.java:90)
 ... 6 more

To fix this, the class should check if the driver supports autocommit before changing the setting.

Metadata

Metadata

Assignees

Labels

featureProduct feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions