Provisionally address issue 46
This commit is contained in:
parent
b5419813ba
commit
61c7a1307e
|
@ -286,10 +286,18 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
||||||
|
|
||||||
def add_statement_event_params(statement, event)
|
def add_statement_event_params(statement, event)
|
||||||
@statement[1..-1].each_with_index do |i, idx|
|
@statement[1..-1].each_with_index do |i, idx|
|
||||||
case event[i]
|
value = event[i]
|
||||||
|
|
||||||
|
if value.nil? and i.to_s =~ /%{/
|
||||||
|
value = event.sprintf(i)
|
||||||
|
else
|
||||||
|
value = i
|
||||||
|
end
|
||||||
|
|
||||||
|
case value
|
||||||
when Time
|
when Time
|
||||||
# See LogStash::Timestamp, below, for the why behind strftime.
|
# See LogStash::Timestamp, below, for the why behind strftime.
|
||||||
statement.setString(idx + 1, event[i].strftime(STRFTIME_FMT))
|
statement.setString(idx + 1, value.strftime(STRFTIME_FMT))
|
||||||
when LogStash::Timestamp
|
when LogStash::Timestamp
|
||||||
# XXX: Using setString as opposed to setTimestamp, because setTimestamp
|
# XXX: Using setString as opposed to setTimestamp, because setTimestamp
|
||||||
# doesn't behave correctly in some drivers (Known: sqlite)
|
# doesn't behave correctly in some drivers (Known: sqlite)
|
||||||
|
@ -298,23 +306,17 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
||||||
# choke on the 'T' in the string (Known: Derby).
|
# choke on the 'T' in the string (Known: Derby).
|
||||||
#
|
#
|
||||||
# strftime appears to be the most reliable across drivers.
|
# strftime appears to be the most reliable across drivers.
|
||||||
statement.setString(idx + 1, event[i].time.strftime(STRFTIME_FMT))
|
statement.setString(idx + 1, value.time.strftime(STRFTIME_FMT))
|
||||||
when Fixnum, Integer
|
when Fixnum, Integer
|
||||||
statement.setInt(idx + 1, event[i])
|
statement.setInt(idx + 1, value)
|
||||||
when Float
|
when Float
|
||||||
statement.setFloat(idx + 1, event[i])
|
statement.setFloat(idx + 1, value)
|
||||||
when String
|
when String
|
||||||
statement.setString(idx + 1, event[i])
|
statement.setString(idx + 1, value)
|
||||||
when true
|
when true, false
|
||||||
statement.setBoolean(idx + 1, true)
|
statement.setBoolean(idx + 1, value)
|
||||||
when false
|
|
||||||
statement.setBoolean(idx + 1, false)
|
|
||||||
else
|
else
|
||||||
if event[i].nil? and i =~ /%\{/
|
statement.setString(idx + 1, nil)
|
||||||
statement.setString(idx + 1, event.sprintf(i))
|
|
||||||
else
|
|
||||||
statement.setString(idx + 1, nil)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -323,13 +325,17 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
||||||
|
|
||||||
def log_jdbc_exception(exception, retrying)
|
def log_jdbc_exception(exception, retrying)
|
||||||
current_exception = exception
|
current_exception = exception
|
||||||
|
log_text = 'JDBC Exception. ' + (retrying ? 'Retrying' : 'No retry') + '.'
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
if retrying
|
@logger.error(log_text, :exception => current_exception, :backtrace => current_exception.backtrace)
|
||||||
@logger.error("JDBC Exception. Retrying.", :exception => current_exception)
|
|
||||||
|
if current_exception.respond_to? 'getNextException'
|
||||||
|
current_exception = current_exception.getNextException()
|
||||||
else
|
else
|
||||||
@logger.error("JDBC Exception. No retry.", :exception => current_exception)
|
current_exception = nil
|
||||||
end
|
end
|
||||||
current_exception = current_exception.getNextException()
|
|
||||||
break if current_exception == nil
|
break if current_exception == nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user