From b52a7358ff98ba2272b9c062fa8fe13976bbba3c Mon Sep 17 00:00:00 2001 From: kushtrim junuzi Date: Wed, 22 Jul 2015 08:06:57 -0400 Subject: [PATCH] Handling null values and added boolean data type.\n Handling jdbc inner exceptions. --- lib/logstash/outputs/jdbc.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index b3127e7..32893fa 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -117,7 +117,13 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base statement.setFloat(idx + 1, event[i]) when String statement.setString(idx + 1, event[i]) - else + when true + statement.setBoolean(idx + 1, true) + when false + statement.setBoolean(idx + 1, false) + when nil + statement.setString(idx + 1, nil) + else statement.setString(idx + 1, event.sprintf(i)) end end @@ -133,6 +139,9 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base # Since the exceutebatch failed this should mean any events failed to be # inserted will be re-run. We're going to log it for the lols anyway. @logger.warn("JDBC - Exception. Will automatically retry", :exception => e) + if e.getNextException() != nil + @logger.warn("JDBC - Exception. Will automatically retry", :exception => e.getNextException()) + end end statement.close()