# JDBC input and JDBC output in one config

**URL:** <https://discuss.elastic.co/t/jdbc-input-and-jdbc-output-in-one-config/184753>\
**Category:** Logstash\
**Created:** [June 7, 2019, 12:44pm UTC](https://discuss.elastic.co/t/jdbc-input-and-jdbc-output-in-one-config/184753 "2019-06-07T12:44:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fesenych](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fesenych](https://discuss.elastic.co/u/fesenych)\
**Post date:** [June 7, 2019, 12:44pm UTC](https://discuss.elastic.co/t/jdbc-input-and-jdbc-output-in-one-config/184753/1 "2019-06-07T12:44:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [June 10, 2019, 8:43pm UTC](https://discuss.elastic.co/t/jdbc-input-and-jdbc-output-in-one-config/184753/2 "2019-06-10T20:43:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fesenych](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fesenych](https://discuss.elastic.co/u/fesenych)\
**Post date:** [June 11, 2019, 7:43am UTC](https://discuss.elastic.co/t/jdbc-input-and-jdbc-output-in-one-config/184753/3 "2019-06-11T07:43:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 9, 2019, 7:43am UTC](https://discuss.elastic.co/t/jdbc-input-and-jdbc-output-in-one-config/184753/4 "2019-07-09T07:43:46Z")

</div>

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