lib/logstash/inputs/jdbc.rb in logstash-integration-jdbc-5.4.0 vs lib/logstash/inputs/jdbc.rb in logstash-integration-jdbc-5.4.1

- old
+ new

@@ -259,12 +259,10 @@ end @last_run_metadata_file_path = @last_run_metadata_path end end - prepare_jdbc_connection - if @use_column_value # Raise an error if @use_column_value is true, but no @tracking_column is set if @tracking_column.nil? raise(LogStash::ConfigurationError, "Must set :tracking_column if :use_column_value is true.") end @@ -303,10 +301,24 @@ converter = LogStash::Util::Charset.new(encoding) converter.logger = self.logger converters[encoding] = converter end end + + load_driver + begin + open_jdbc_connection + rescue Sequel::DatabaseConnectionError, + Sequel::DatabaseError, + Sequel::InvalidValue, + Java::JavaSql::SQLException => e + details = { exception: e.class, message: e.message } + details[:cause] = e.cause.inspect if e.cause + details[:backtrace] = e.backtrace if @logger.debug? + @logger.warn("Exception when executing JDBC query", details) + raise(LogStash::ConfigurationError, "Can't create a connection pool to the database") + end end # def register # test injection points def set_statement_handler(handler) @statement_handler = handler @@ -315,10 +327,9 @@ def set_value_tracker(instance) @value_tracker = instance end def run(queue) - load_driver if @schedule # scheduler input thread name example: "[my-oracle]|input|jdbc|scheduler" scheduler.cron(@schedule) { execute_query(queue) } scheduler.join else