# Logstash JDBC importer MSSQL2012 is not working

**URL:** https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926
**Category:** Logstash
**Created:** [March 31, 2016, 11:44am UTC](https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926 "2016-03-31T11:44:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![PascalR](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@PascalR](https://discuss.elastic.co/u/PascalR)
#### Post date: [March 31, 2016, 11:44am UTC](https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926/1 "2016-03-31T11:44:25Z")

</div>

Hi,

I'm completely stuck.  
I tried to import data from an MSSQL2012 database to elasticsearch, but it's not working.

Here are the steps I've done:

1. Started Elasticsearch 2.2.0
2. Downloaded Logstash-all-plugins-2.2.0
3. Downloaded Elasticsearch-jdbc-2.2.0 from GitHub
4. Created a .conf file like this:

> input {  
> jdbc {  
> jdbc\_driver\_library =\> "D:\temp\sqljdbc\sqljdbc\_4.2\enu\sqljdbc42.jar"  
> jdbc\_driver\_class =\> "com.microsoft.sqlserver.jdbc.SQLServerDriver"  
> jdbc\_connection\_string =\> "jdbc:sqlserver://DBSVR\_NAME;user= **;password=** ;"  
> jdbc\_user =\> "**"  
> jdbc\_password =\> "**"  
> statement =\> "SELECT \*  
> FROM [DB].[SCHEMA].[TABLE]"  
> }  
> }  
> filter {  
> }  
> output {  
> elasticsearch {  
> host =\> "localhost"  
> index =\> "INDEX\_NAME"  
> document\_type =\> "DOCUMENT\_TYPE"  
> document\_id =\> "%{id}"  
> protocol =\> "http"  
> }  
> stdout { codec =\> rubydebug }  
> }

1. Started Logstash with the command "logstash -f db.conf"
2. Got an error message that said: "Java::net.sourceforge.jtds.jdbc.Driver not loaded, try install jdbc-jtds gem"
3. Downloaded the latest jtds .jar and now I don't know what to do.

I've tried other drivers an they didn't work either.

I don't know if this is necessary but the system is a Windows 7 Professional x64.

I'm thankful for any help or alternatives that help me to get my sql data to elasticsearch.

---

<div class="post-metadata">

### Author: ![mick66](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@mick66](https://discuss.elastic.co/u/mick66)
#### Post date: [March 31, 2016, 3:32pm UTC](https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926/2 "2016-03-31T15:32:39Z")

</div>

Your config does not look correct to me. I have this working against SQL 2012 with the following configuration:

```
 jdbc {
            jdbc_driver_library => "/PATH/sqljdbc4.jar"
            jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
            jdbc_connection_string => "jdbc:sqlserver://SERVERNAME:PORT;databaseName=DBNAME"
            jdbc_user => "USER"
            jdbc_password => "PASSWORD"
            statement => "SELECT BLAH'
}

```

If you are running a named instance on the SQL Server, then it will likely have a dynamic port allocated, so this number will need to be confirmed from your DBA

---

<div class="post-metadata">

### Author: ![vikram\_yerneni](https://avatars.discourse-cdn.com/v4/letter/v/3ab097/32.png) [@vikram\_yerneni](https://discuss.elastic.co/u/vikram_yerneni)
#### Post date: [March 31, 2016, 4:51pm UTC](https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926/3 "2016-03-31T16:51:52Z")

</div>

Thats right.. it seems the issue is with the jdbc connection string.. I use the same 2012 setup with the syntax:  
jdbc\_connection\_string =\> "jdbc:sqlserver://SQLServername\instance:port;"

Hope this helps.  
Vikram Y

---

<div class="post-metadata">

### Author: ![PascalR](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@PascalR](https://discuss.elastic.co/u/PascalR)
#### Post date: [April 1, 2016, 12:00pm UTC](https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926/4 "2016-04-01T12:00:58Z")

</div>

Thanks, I'll try it and tell you if it's working!

---

<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, 5:04am UTC](https://discuss.elastic.co/t/logstash-jdbc-importer-mssql2012-is-not-working/45926/5 "2017-07-06T05:04:20Z")

</div>


