From 6b6973d6ee43588446dca0948443d00907ef6f64 Mon Sep 17 00:00:00 2001 From: Karl Southern Date: Fri, 26 Jun 2015 12:45:45 +0100 Subject: [PATCH] Fixes up 1.5+ compatibility --- lib/logstash/outputs/jdbc.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index 16737ee..b3127e7 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -9,7 +9,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base include Stud::Buffer config_name "jdbc" - milestone 1 # Driver class config :driver_class, :validate => :string @@ -50,11 +49,21 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base public def register + @logger.info("JDBC - Starting up") - jarpath = File.join(File.dirname(__FILE__), "../../../vendor/jar/jdbc/*.jar") - @logger.info(jarpath) - Dir[jarpath].each do |jar| + if ENV['LOGSTASH_HOME'] + jarpath = File.join(ENV['LOGSTASH_HOME'], "/vendor/jar/jdbc/*.jar") + else + jarpath = File.join(File.dirname(__FILE__), "../../../vendor/jar/jdbc/*.jar") + end + + @logger.debug("JDBC - jarpath", path: jarpath) + + jars = Dir[jarpath] + raise Exception.new("JDBC - No jars found in jarpath. Have you read the README?") if jars.empty? + + jars.each do |jar| @logger.debug("JDBC - Loaded jar", :jar => jar) require jar end @@ -99,7 +108,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base @statement[1..-1].each_with_index do |i, idx| case event[i] - when Time + when Time, LogStash::Timestamp # Most reliable solution, cross JDBC driver statement.setString(idx + 1, event[i].iso8601()) when Fixnum, Integer