Fixes up 1.5+ compatibility

This commit is contained in:
Karl Southern 2015-06-26 12:45:45 +01:00
parent c790a645f2
commit 6b6973d6ee

View File

@ -9,7 +9,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
include Stud::Buffer include Stud::Buffer
config_name "jdbc" config_name "jdbc"
milestone 1
# Driver class # Driver class
config :driver_class, :validate => :string config :driver_class, :validate => :string
@ -50,11 +49,21 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
public public
def register def register
@logger.info("JDBC - Starting up") @logger.info("JDBC - Starting up")
jarpath = File.join(File.dirname(__FILE__), "../../../vendor/jar/jdbc/*.jar") if ENV['LOGSTASH_HOME']
@logger.info(jarpath) jarpath = File.join(ENV['LOGSTASH_HOME'], "/vendor/jar/jdbc/*.jar")
Dir[jarpath].each do |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) @logger.debug("JDBC - Loaded jar", :jar => jar)
require jar require jar
end end
@ -99,7 +108,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
@statement[1..-1].each_with_index do |i, idx| @statement[1..-1].each_with_index do |i, idx|
case event[i] case event[i]
when Time when Time, LogStash::Timestamp
# Most reliable solution, cross JDBC driver # Most reliable solution, cross JDBC driver
statement.setString(idx + 1, event[i].iso8601()) statement.setString(idx + 1, event[i].iso8601())
when Fixnum, Integer when Fixnum, Integer