From 529c98aadb91dcb6e8a3db8ae976ad543178e8b8 Mon Sep 17 00:00:00 2001 From: Karl Southern Date: Wed, 23 Dec 2015 10:06:50 +0000 Subject: [PATCH] Addresses 22 not giving warning about incorrectly configured statements --- README.md | 5 ++++- lib/logstash/outputs/jdbc.rb | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d5a5a69..e1f1cb2 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,9 @@ particular location. Please ensure you read the 4 installation lines below. - Altered exception handling to now count sequential flushes with exceptions thrown in 0.2.0 ## Versions +Released versions are are tagged as of v0.2.1, and available via rubygems. + +For development: - See master branch for logstash v2+ - See v1.5 branch for logstash v1.5 - See v1.4 branch for logstash 1.4 @@ -24,7 +27,7 @@ particular location. Please ensure you read the 4 installation lines below. ## Installation - Run `bin/plugin install logstash-output-jdbc` in your logstash installation directory - Now either: - - Use driver_class in your configuraton to specify a path to your jar file + - Use driver_path in your configuraton to specify a path to your jar file - Or: - Create the directory vendor/jar/jdbc in your logstash installation (`mkdir -p vendor/jar/jdbc/`) - Add JDBC jar files to vendor/jar/jdbc in your logstash installation diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index e666ebb..1db7d45 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -102,6 +102,14 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base @logger.warn("JDBC - Flush size is set to > 1000") end + if @statement.length < 1 + @logger.error("JDBC - No statement provided. Configuration error.") + end + + if (!@unsafe_statement and @statement.length < 2) + @logger.error("JDBC - Statement has no parameters. No events will be inserted into SQL as you're not passing any event data. Likely configuration error.") + end + buffer_initialize( :max_items => @flush_size, :max_interval => @idle_flush_time,