JDBC input and JDBC output in one config

Hi, I am trying to configure JDBC input and JDBC output in one configuration file. When in the configuration file is configured only on JDBC input or JDBC output, then everything works well when I try to combine them in one configuration file, I get an error:

[ERROR][org.logstash.Logstash ] java.lang.IllegalAccessError: tried to access method com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.(Lcom/microsoft/sqlserver/jdbc/SQLServerConnection;Ljava/lang/String;IILcom/microsoft/sqlserver/jdbc/SQLServerStatementColumnEncryptionSetting;)V from class com.microsoft.sqlserver.jdbc.SQLServerConnection

My config:

input {
  beats {
    port => "5044"
  }
  jdbc {
    jdbc_driver_library => "/usr/share/logstash/sqljdbc_7.2/mssql-jdbc-7.2.2.jre8.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://10.0.0.2:1433;databaseName=bilet"
    jdbc_user => "logstash"
    jdbc_password => "qwerty"
    schedule => "* * * * *"
    statement => "SELECT * FROM [bilet].[dbo].[ticket_order_item_rzv] where tor_id > :sql_last_value"
    tracking_column => "tor_id"
#    tracking_column_type => "timestamp"
    last_run_metadata_path => "/usr/share/logstash/last_run"
    use_column_value => true
    tags => ["tickets_sold"]
  }
}
filter {
  if "tksmail_postfix" in [tags] {
    if "status" in [message] {
      grok {
        patterns_dir => ["/etc/logstash/patterns"]
        match => { "message" => "^%{MYDATE:mydate}.%{TIME:mytime}\+\d\d:\d\d %{HOSTNAME:logsource}.*?%{QUEUEID:qid}.*?%{TO_MAIL:email}>.*?%{DSN:dsn}, status=%{STATUS:status}" }
        add_tag => [ "tksmail_mail_status" ]
        }
    }
    else if "X-TKS-Platform-BulkMessageID:" in [message] {
      grok {
        patterns_dir => ["/etc/logstash/patterns"]
        match => { "message" => "^%{MYDATE:mydate}.%{TIME:mytime}\+\d\d:\d\d %{HOSTNAME:logsource}.*?%{QUEUEID:qid}: info: header X-TKS-Platform-BulkMessageID: %{BULKID:BulkMessageID}.*?%{
        add_tag => [ "tksmail_bulkid" ]
      }
    }
  }
}

filter {
  mutate {
      add_field => { "timestamp" => "%{mydate} %{mytime}" }
      add_field => { "mail_key" => "%{mydate};%{qid};%{email}" }
  }
}
output {
  if "tksmail_mail_status" in [tags] {
      jdbc {
#        driver_jar_path => "/usr/share/logstash/sqljdbc42.jar"
        driver_jar_path => "/usr/share/logstash/sqljdbc_7.2/mssql-jdbc-7.2.2.jre8.jar"
        connection_string => "jdbc:sqlserver://10.0.0.2:1433;databaseName=bilet;user=logstash;password=qwerty"
        statement => [ "INSERT INTO mail_log_status (timestamp, logsource, qid, email, dsn, status, mail_key) VALUES(?, ?, ?, ?, ?, ?, ?)", "timestamp", "logsource", "qid","email", "dsn",
  }
  else if "tksmail_bulkid" in [tags] {
    jdbc {
#        driver_jar_path => "/usr/share/logstash/sqljdbc42.jar"
        driver_jar_path => "/usr/share/logstash/sqljdbc_7.2/mssql-jdbc-7.2.2.jre8.jar"
        connection_string => "jdbc:sqlserver://10.0.0.2:1433;databaseName=bilet;user=logstash;password=qwerty"
        statement => [ "INSERT INTO mail_log_BulkMessageID (timestamp, logsource, qid, BulkMessageID, email, mail_key) VALUES(?, ?, ?, ?, ?, ?)", "timestamp", "logsource", "qid", "BulkMess
  }
  else if "tickets_sold" in [tags] {
    elasticsearch {
        hosts => [ "localhost:9200" ]
        index => "tickets_sold"
        document_type => "tickets"
        document_id => "%{tor_id}"
        }
    }
}

How to solve this problem?

Try using two different users one that has read only access to your database and one that has writing access.

I have tried with two different users but the error persists.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.