# Logstash invalid byte sequence in UTF-8 jdbc input

**URL:** <https://discuss.elastic.co/t/logstash-invalid-byte-sequence-in-utf-8-jdbc-input/194876>\
**Category:** Logstash\
**Created:** [August 12, 2019, 3:40pm UTC](https://discuss.elastic.co/t/logstash-invalid-byte-sequence-in-utf-8-jdbc-input/194876 "2019-08-12T15:40:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick36](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@nick36](https://discuss.elastic.co/u/nick36)\
**Post date:** [August 12, 2019, 3:40pm UTC](https://discuss.elastic.co/t/logstash-invalid-byte-sequence-in-utf-8-jdbc-input/194876/1 "2019-08-12T15:40:23Z")

</div>

Hi,  
I have a problem with an error invalid byte sequence in UTF-8. Logstash 7.3.0.

conf below:  
input{  
jdbc{  
jdbc\_driver\_library =\> "C:\sqljdbc42.jar"  
jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
jdbc\_connection\_string =\> "jdbc:sqlserver://MYSERVER;integratedsecurity=true;databaseName=Db;"  
jdbc\_user =\> "user"  
jdbc\_password =\> ""  
jdbc\_validate\_connection =\> true  
jdbc\_pool\_timeout =\> 10  
jdbc\_default\_timezone =\> "Etc/UTC"  
connection\_retry\_attempts =\> 3  
connection\_retry\_attempts\_wait\_time =\> 2  
lowercase\_column\_names =\> false  
statement\_filepath =\> "C:\sql\_1.sql"  
schedule =\> "3 \* \* \* \* \*"  
codec =\> line { charset =\> "UTF-8" }  
}  
}

output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200)"]  
index =\> "my\_pattern"  
}  
}

An error:  
{ 2048 rufus-scheduler intercepted an error:  
2048 job:  
2048 Rufus::Scheduler::CronJob "3 \* \* \* \* \*" {}  
2048 error:  
2048 2048  
2048 ArgumentError  
2048 invalid byte sequence in UTF-8  
2048 org/jruby/RubyString.java:4790:in `partition' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/sql.rb:600:in`placeholder\_literal\_string\_sql\_append'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/sql.rb:112:in `to_s_append' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/sql.rb:1236:in`literal\_expression\_append'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/sql.rb:89:in `literal_append' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/sql.rb:263:in`literal'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/sql.rb:1581:in `static_sql' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/sql.rb:236:in`select\_sql'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/adapters/utils/emulate\_offset\_with\_row\_number.rb:45:in `select_sql' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/adapters/shared/mssql.rb:664:in`select\_sql'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/sequel-5.22.0/lib/sequel/dataset/actions.rb:152:in `each' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:257:in`perform\_query'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin\_mixins/jdbc/jdbc.rb:229:in `execute_statement' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:277:in`execute\_query'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:258:in `block in run' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:234:in`do\_call'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:258:in `do_trigger' 2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:300:in`block in start\_work\_thread'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:299:in `block in start_work_thread' 2048 org/jruby/RubyKernel.java:1425:in`loop'  
2048 C:/Elastic/Logstash/7.3.0/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:289:in `block in start\_work\_thread'  
2048 tz:  
2048 ENV['TZ']:  
2048 Time.now: 2019-08-12 17:39:03 +0200  
2048 scheduler:  
2048 object\_id: 2012  
2048 opts:  
2048 {:max\_work\_threads=\>1}  
2048 frequency: 0.3  
2048 scheduler\_lock: #Rufus::Scheduler::NullLock:0x7116ed8d  
2048 trigger\_lock: #Rufus::Scheduler::NullLock:0x7ef55089  
2048 uptime: 4250.077 (1h10m50s77)  
2048 down?: false  
2048 threads: 2  
2048 thread: #Thread:0x46af4b51  
2048 thread\_key: rufus\_scheduler\_2012  
2048 work\_threads: 1  
2048 active: 1  
2048 vacant: 0  
2048 max\_work\_threads: 1  
2048 mutexes: {}  
2048 jobs: 1  
2048 at\_jobs: 0  
2048 in\_jobs: 0  
2048 every\_jobs: 0  
2048 interval\_jobs: 0  
2048 cron\_jobs: 1  
2048 running\_jobs: 1  
2048 work\_queue: 0  
} 2048 .

What is missing?

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [August 12, 2019, 4:56pm UTC](https://discuss.elastic.co/t/logstash-invalid-byte-sequence-in-utf-8-jdbc-input/194876/2 "2019-08-12T16:56:30Z")

</div>

The jdbc input does not use a codec because the data it is getting from jdbc is already structured.

From the backtrace, I can see that the error occurs when the SQL statement is being built before it get sent to the server for execution, i.e. on the way up not on the way down.

The most likely problem is with the `statement_filepath => "C:\sql_1.sql"`, the actual file is assumed to be UTF-8 - is it in a different encoding?

---

<div class="post-metadata">

**Author:** ![nick36](https://avatars.discourse-cdn.com/v4/letter/n/838e76/32.png) [@nick36](https://discuss.elastic.co/u/nick36)\
**Post date:** [August 12, 2019, 5:30pm UTC](https://discuss.elastic.co/t/logstash-invalid-byte-sequence-in-utf-8-jdbc-input/194876/3 "2019-08-12T17:30:50Z")

</div>

Yes, it was this problem, thank you!

---

<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:** [September 9, 2019, 5:30pm UTC](https://discuss.elastic.co/t/logstash-invalid-byte-sequence-in-utf-8-jdbc-input/194876/4 "2019-09-09T17:30:53Z")

</div>

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