# Trying to connect to mssql server with JDBC

**URL:** <https://discuss.elastic.co/t/trying-to-connect-to-mssql-server-with-jdbc/57003>\
**Category:** Logstash\
**Created:** [August 2, 2016, 12:02pm UTC](https://discuss.elastic.co/t/trying-to-connect-to-mssql-server-with-jdbc/57003 "2016-08-02T12:02:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![valky05](https://avatars.discourse-cdn.com/v4/letter/v/f14d63/32.png) [@valky05](https://discuss.elastic.co/u/valky05)\
**Post date:** [August 2, 2016, 12:02pm UTC](https://discuss.elastic.co/t/trying-to-connect-to-mssql-server-with-jdbc/57003/1 "2016-08-02T12:02:52Z")

</div>

I'm currently trying to connect to a remote MSsql server with the JDBC plugin of Logstash.

For the config file, I use the syntax proposed by mick66 on this thread: [Jdbc MSSql Server Connection](https://discuss.elastic.co/t/jdbc-mssql-server-connection/44324)

My config file is thus:

```
input {
  jdbc {
    jdbc_driver_library => "/etc/logstash/sqljdbc4-3.0.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://IPADDRESS:1433;databasename=MYDBNAME"
    jdbc_user => "USER"
    jdbc_password => "PASSWORD"
    schedule => "* * * * *"
    statement => "SELECT COUNT(*) FROM Table"
  }
}
output {
    elasticsearch {
        protocol => http
        index => "SqlData"
        document_type => "Counter"
        hosts => ["localhost:9200"]
    }
}

```

However, I have the error:

```
message=>"Pipeline aborted due to error", :exception=>#<LogStash::ConfigurationError: Something is wrong with your configuration.>, :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/config/mixin.rb:134:in `config_init'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/outputs/base.rb:63:in `initialize'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/output_delegator.rb:74:in `register'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:181:in `start_workers'", "org/jruby/RubyArray.java:1613:in `each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:181:in `start_workers'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:136:in `run'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/agent.rb:473:in `start_pipeline'"], :level=>:error}
{:timestamp=>"2016-08-02T13:37:07.250000+0200", :message=>"stopping pipeline", :id=>"main"}

```

Which seems to say that the syntax of the config file is not correct. The problem seems to be the "databasename=DATABASE" part. However, I found that the syntax for a connection to a MSsql database is:

`jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]`

Which is the syntax that I respected.

I try then to replace the " **jdbc\_connection\_string**" by:

`jdbc_connection_string => "jdbc:sqlserver://IPADDRESS:1433/MYDBNAME"`

The config seems then to be correct (no ConfigurationError) but logstash triggers an error that says that the port "1433/MYDBNAME" is incorrect. This syntax seems thus also innapropriate.

This leads to my main question: What is the appropriate syntax for the logstash config file if we want to connect to a MSsql server using the JDBC plugin ?

**Edit** : I already checked that the MSsql server is well running and that its IP/TCP config is well active as mentionned in a great deal of posts on the Internet.

---

<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 6, 2017, 4:45am UTC](https://discuss.elastic.co/t/trying-to-connect-to-mssql-server-with-jdbc/57003/2 "2017-07-06T04:45:20Z")

</div>


