You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2024/02/05 17:59:38 UTC
(tika) branch TIKA-4190 created (now d7561152d)
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a change to branch TIKA-4190
in repository https://gitbox.apache.org/repos/asf/tika.git
at d7561152d TIKA-4190 -- turn off autocommit
This branch includes the following new commits:
new d7561152d TIKA-4190 -- turn off autocommit
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(tika) 01/01: TIKA-4190 -- turn off autocommit
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch TIKA-4190
in repository https://gitbox.apache.org/repos/asf/tika.git
commit d7561152d40706f5cac128f8af6cf733c6520189
Author: tallison <ta...@apache.org>
AuthorDate: Mon Feb 5 12:59:29 2024 -0500
TIKA-4190 -- turn off autocommit
---
.../org/apache/tika/pipes/emitter/jdbc/JDBCEmitter.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tika-pipes/tika-emitters/tika-emitter-jdbc/src/main/java/org/apache/tika/pipes/emitter/jdbc/JDBCEmitter.java b/tika-pipes/tika-emitters/tika-emitter-jdbc/src/main/java/org/apache/tika/pipes/emitter/jdbc/JDBCEmitter.java
index e72d6ba19..0e3f2cb04 100644
--- a/tika-pipes/tika-emitters/tika-emitter-jdbc/src/main/java/org/apache/tika/pipes/emitter/jdbc/JDBCEmitter.java
+++ b/tika-pipes/tika-emitters/tika-emitter-jdbc/src/main/java/org/apache/tika/pipes/emitter/jdbc/JDBCEmitter.java
@@ -304,7 +304,17 @@ public class JDBCEmitter extends AbstractEmitter implements Initializable, Close
insertAll(d.getEmitKey().getEmitKey(), d.getMetadataList());
}
}
- insertStatement.executeBatch();
+ if (LOGGER.isDebugEnabled()) {
+ long start = System.currentTimeMillis();
+ insertStatement.executeBatch();
+ connection.commit();
+ LOGGER.debug("took {}ms to insert {} rows ", System.currentTimeMillis() - start,
+ emitData.size());
+ } else {
+ insertStatement.executeBatch();
+ connection.commit();
+ }
+
}
private void insertAll(String emitKey, List<Metadata> metadataList) throws SQLException {
@@ -361,6 +371,7 @@ public class JDBCEmitter extends AbstractEmitter implements Initializable, Close
if (connection != null) {
try {
+ connection.commit();
connection.close();
} catch (SQLException e) {
LOGGER.warn("exception closing connection", e);
@@ -370,6 +381,7 @@ public class JDBCEmitter extends AbstractEmitter implements Initializable, Close
private void createConnection() throws SQLException {
connection = DriverManager.getConnection(connectionString);
+ connection.setAutoCommit(false);
if (postConnectionString.isPresent()) {
try (Statement st = connection.createStatement()) {
st.execute(postConnectionString.get());