# Jdbc connection to MS-SQL server with windows credentials

**URL:** <https://discuss.elastic.co/t/jdbc-connection-to-ms-sql-server-with-windows-credentials/264542>\
**Category:** Logstash\
**Created:** [February 17, 2021, 9:38am UTC](https://discuss.elastic.co/t/jdbc-connection-to-ms-sql-server-with-windows-credentials/264542 "2021-02-17T09:38:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravnen.flyver](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@ravnen.flyver](https://discuss.elastic.co/u/ravnen.flyver)\
**Post date:** [February 17, 2021, 9:38am UTC](https://discuss.elastic.co/t/jdbc-connection-to-ms-sql-server-with-windows-credentials/264542/1 "2021-02-17T09:38:01Z")

</div>

I am sitting on a WindownServer(2019) where I connect to a Windown sql 2016 server.

On my WindownServer I can connect to the SQL server through MS SQL Management Studio, so firewall and all that is ok. And my Windown AD user has access to the database.  
But never the less I'm getting this error and the server admin can see the failed login in the server log.

> [2021-02-17T09:51:47,984][ERROR][logstash.inputs.jdbc][main][b08b71f174442b8dc3be807457a72d9cc857de10bcd897f7bb70ac01896eb657] Unable to connect to database. Tried 1 times {:error\_message=\>"Java::ComMicrosoftSqlserverJdbc::SQLServerException: Login failed for user 'USER@DOMAIN.local'. ClientConnectionId:19be6378-d3a2-46bd-b589-ed0542a1bba2"}

This is my conf file

```
input {
      jdbc {
        jdbc_driver_library => "C:/logstash-7.10.2/logstash-core/lib/jars/mssql-jdbc-9.2.0.jre11.jar" 
        jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"     
        jdbc_connection_string =>"jdbc:sqlserver://SQLSERVER.DOMAIN.local:1433
            ;database=DATABASE
            ;user=USER@DOMAIN.local
            ;password=PASSWORD
            ;trustServerCertificate=false
            ;hostNameInCertificate=*.DOMAIN.local
            ;loginTimeout=30
            ;domain=DOMAIN.local
            ;Trusted_Connection=True
            ;authenticationScheme=JavaKerberos
            ;encrypt=false;" 
        jdbc_user => "USER@DOMAIN.local"
        jdbc_password => "PASSWORD"
        statement_filepath => "C:/logstash-7.10.2/bin/test.sql"
      }
    }

```

I am fairly certain that everything is setup right. I do see other [posts](https://discuss.elastic.co/t/does-logstash-jdbc-connection-work-with-windows-authentication/141562) with similar issues, but they are several years old, and much have happened with logstash since then, that is why I ask again. I properly have unnecessary elements in my connection string, but I am running out of idears.

_Help my Obi-Elastic, you are my only hope_

---

<div class="post-metadata">

**Author:** ![ErikWarming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/erikwarming/32/39525_2.png) [@ErikWarming](https://discuss.elastic.co/u/ErikWarming)\
**Post date:** [February 19, 2021, 1:10pm UTC](https://discuss.elastic.co/t/jdbc-connection-to-ms-sql-server-with-windows-credentials/264542/2 "2021-02-19T13:10:29Z")

</div>

Found the answer to the problem: The jdbc driver was to new (!?)  
The **mssql-jdbc-9.2.0.jar** is aparently incompadable with java 11 while with **mssql-jdbc-7.2.2.jre11.jar** it worked

[systems requirements for the jdbc driver](https://docs.microsoft.com/en-us/sql/connect/jdbc/system-requirements-for-the-jdbc-driver?view=sql-server-ver15)

---

<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:** [March 19, 2021, 1:10pm UTC](https://discuss.elastic.co/t/jdbc-connection-to-ms-sql-server-with-windows-credentials/264542/3 "2021-03-19T13:10:30Z")

</div>

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