Mild fix ups
This commit is contained in:
		
							parent
							
								
									521b43a950
								
							
						
					
					
						commit
						3ac6e61152
					
				@ -9,7 +9,7 @@ This has not yet been extensively tested with all JDBC drivers and may not yet w
 | 
			
		||||
 | 
			
		||||
Installation
 | 
			
		||||
------------
 | 
			
		||||
  - Copy logstash directory contents into your logstash installation.
 | 
			
		||||
  - Copy lib directory contents into your logstash installation.
 | 
			
		||||
  - Add JDBC jar files to vendor/jar/jdbc in your logstash installation
 | 
			
		||||
  - Configure
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
 | 
			
		||||
  public
 | 
			
		||||
  def register
 | 
			
		||||
    @logger.info("Starting up JDBC")
 | 
			
		||||
    require 'java'
 | 
			
		||||
    require "java"
 | 
			
		||||
 | 
			
		||||
    jarpath = File.join(File.dirname(__FILE__), "../../../vendor/jar/jdbc/*.jar")
 | 
			
		||||
    @logger.info(jarpath)
 | 
			
		||||
@ -33,15 +33,25 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
 | 
			
		||||
    driver = Object.const_get(@driver_class[@driver_class.rindex('.') + 1, @driver_class.length]).new
 | 
			
		||||
    @connection = driver.connect(@connection_string, java.util.Properties.new)
 | 
			
		||||
 | 
			
		||||
    @logger.debug("JDBC", :connection => @connection)
 | 
			
		||||
    @logger.debug("JDBC", :driver => driver, :connection => @connection)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def receive(event)
 | 
			
		||||
    return unless output?(event)
 | 
			
		||||
    return unless @statement.length > 0
 | 
			
		||||
 | 
			
		||||
    statement = @connection.prepareStatement(@statement[0])
 | 
			
		||||
    @statement[1..-1].each_with_index { |i, idx| statement.setString(idx + 1, event.sprintf(i)) }
 | 
			
		||||
    @statement[1..-1].each_with_index { |i, idx| statement.setString(idx + 1, event.sprintf(i)) } if @statement.length > 1
 | 
			
		||||
 | 
			
		||||
    @logger.debug("Sending SQL to server", :event => event, :sql => statement.toString())
 | 
			
		||||
 | 
			
		||||
    statement.executeUpdate()
 | 
			
		||||
    statement.close()
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def teardown
 | 
			
		||||
    @connection.close()
 | 
			
		||||
    super
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end # class LogStash::Outputs::jdbc
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user