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 2022/09/02 14:32:38 UTC
[tika] branch main updated: add float to jdbcemitter
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new a6c732f04 add float to jdbcemitter
a6c732f04 is described below
commit a6c732f04b4cc2d83f5977e55182d978e31ff064
Author: tballison <ta...@apache.org>
AuthorDate: Fri Sep 2 10:32:24 2022 -0400
add float to jdbcemitter
---
.../java/org/apache/tika/pipes/emitter/jdbc/JDBCEmitter.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
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 330515858..274ae5d6c 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
@@ -233,12 +233,24 @@ public class JDBCEmitter extends AbstractEmitter implements Initializable, Close
case "long":
updateLong(insertStatement, i, val);
break;
+ case "float":
+ updateFloat(insertStatement, i, val);
+ break;
default:
throw new IllegalArgumentException("Can only process: 'string', 'boolean', 'int' " +
"and 'long' types so far. Please open a ticket to request other types");
}
}
+ private void updateFloat(PreparedStatement insertStatement, int i, String val)
+ throws SQLException {
+ if (StringUtils.isBlank(val)) {
+ insertStatement.setNull(i, Types.FLOAT);
+ } else {
+ insertStatement.setFloat(i, Float.parseFloat(val));
+ }
+ }
+
private void updateLong(PreparedStatement insertStatement, int i, String val)
throws SQLException {
if (StringUtils.isBlank(val)) {