# Unable to connect to SQL Server 2008 R2 on Windows 7

**URL:** <https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607>\
**Category:** Logstash\
**Created:** [May 4, 2019, 7:05am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607 "2019-05-04T07:05:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rudraroy](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rudraroy](https://discuss.elastic.co/u/rudraroy)\
**Post date:** [May 4, 2019, 7:05am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/1 "2019-05-04T07:05:20Z")

</div>

I am running logstash 7.0 on Windows 7 with below configuration  
SQL Server 2008 R2 (Remote)  
jdbc verson 6.0.  
I have also used jdbc 4.0 same error is received.

java version "1.8.0\_211"  
Java(TM) SE Runtime Environment (build 1.8.0\_211-b12)  
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

E:/Logging/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin\_mixins/jdbc/jdbc.rb:221:in `execute_statement' E:/Logging/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:277:in` execute\_query'  
E:/Logging/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:263:in `run' E:/Logging/logstash-7.0.0/logstash-core/lib/logstash/java_pipeline.rb:297:in` inputworker'  
E:/Logging/logstash-7.0.0/logstash-core/lib/logstash/java\_pipeline.rb:290:in `block in start_input' [2019-05-03T16:05:04,296][WARN][logstash.runner] SIGINT received. Shutting down. [2019-05-03T16:05:04,470][ERROR][logstash.inputs.jdbc] Failed to load sqljdbc42.jar {:exception=>#<TypeError: failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader>} [2019-05-03T16:05:04,474][ERROR][logstash.javapipeline] A plugin had an unrecoverable error. Will restart this plugin. Pipeline_id:main Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"nil", statement=>"SELECT * FROM Table", jdbc_driver_library=>"sqljdbc42.jar", jdbc_connection_string=>"jdbc:sqlserver://server\\instance:1433;database=database;integratedSecurity=true", id=>"cfbecab99275f6f092994137c5b73e129c04590230b5f432bc56802110950dea", jdbc_driver_class=>"com.microsoft.sqlserver.jdbc.SQLServerDriver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_20a20956-de89-44ac-b243-70063a80d6a0", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, parameters=>{"sql_last_value"=>1970-01-01 00:00:00 UTC}, last_run_metadata_path=>"C:\\Users\\username/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true> **Error: com.microsoft.sqlserver.jdbc.SQLServerDriver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library? Exception: LogStash::ConfigurationError** Stack: E:/Logging/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:163:in` open\_jdbc\_connection'

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 4, 2019, 7:06am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/2 "2019-05-04T07:06:03Z")

</div>

> [@rudraroy](#):
>
> Error: com.microsoft.sqlserver.jdbc.SQLServerDriver not loaded. Are you sure you've included the correct jdbc driver in :jdbc\_driver\_library?

Did you double check that?

---

<div class="post-metadata">

**Author:** ![rudraroy](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rudraroy](https://discuss.elastic.co/u/rudraroy)\
**Post date:** [May 4, 2019, 7:28am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/3 "2019-05-04T07:28:04Z")

</div>

Yes. I did.

---

<div class="post-metadata">

**Author:** ![staodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/staodd/32/24509_2.png) [@staodd](https://discuss.elastic.co/u/staodd)\
**Post date:** [May 4, 2019, 7:30am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/4 "2019-05-04T07:30:34Z")

</div>

Apparently not. Could you at least include your config??

---

<div class="post-metadata">

**Author:** ![rudraroy](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rudraroy](https://discuss.elastic.co/u/rudraroy)\
**Post date:** [May 4, 2019, 7:32am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/5 "2019-05-04T07:32:53Z")

</div>

```
input {
  jdbc {
    jdbc_driver_library => "sqljdbc42.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_user => "userame"
    jdbc_connection_string => "jdbc:sqlserver://server\\instance:1433;database=database;integratedSecurity=true"
	jdbc_password => "xxx"
	statement => "SELECT * FROM table1"
  }
}

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "cs_users"
	#document_id => "%{Id}"
  }
}
```

---

<div class="post-metadata">

**Author:** ![staodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/staodd/32/24509_2.png) [@staodd](https://discuss.elastic.co/u/staodd)\
**Post date:** [May 4, 2019, 9:49am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/6 "2019-05-04T09:49:10Z")

</div>

Please read up on formatting code when posting. Lots of people will skip reading if its not formatted. And this is not all of your config. Where is the sqljdbc42.jar file located in the file system. Do you know that logstash finds it when it starts?

---

<div class="post-metadata">

**Author:** ![rudraroy](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rudraroy](https://discuss.elastic.co/u/rudraroy)\
**Post date:** [May 4, 2019, 9:56am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/7 "2019-05-04T09:56:05Z")

</div>

sqljdbc42.jar is located within logstash/bin directory. Even I have tried with explicit path and got same error.

---

<div class="post-metadata">

**Author:** ![rudraroy](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rudraroy](https://discuss.elastic.co/u/rudraroy)\
**Post date:** [May 4, 2019, 9:59am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/8 "2019-05-04T09:59:22Z")

</div>

```
input {
jdbc {
              jdbc_driver_library => "sqljdbc42.jar"
              jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
              jdbc_user => "userame"
              dbc_connection_string=>
              "jdbc:sqlserver://server\instance:1433;
               database=database;integratedSecurity=true"
               jdbc_password => "xxx"
               statement => "SELECT * FROM table1"
}
}

output {
elasticsearch {
                       hosts => ["localhost:9200"]
                       index => "cs_users"
                       #document_id => "%{Id}"
}
}
```

---

<div class="post-metadata">

**Author:** ![rudraroy](https://avatars.discourse-cdn.com/v4/letter/r/f04885/32.png) [@rudraroy](https://discuss.elastic.co/u/rudraroy)\
**Post date:** [May 4, 2019, 11:47pm UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/9 "2019-05-04T23:47:11Z")

</div>

Is there any way to debug this condition Logstash not able to find sqljdbc42.jar present in Logstash\bin.

---

<div class="post-metadata">

**Author:** ![balumurari1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balumurari1/32/39203_2.png) [@balumurari1](https://discuss.elastic.co/u/balumurari1)\
**Post date:** [May 10, 2019, 9:53am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/10 "2019-05-10T09:53:56Z")

</div>

try this,

```
input {

    jdbc {
    jdbc_driver_library => "C:/Users/xxxx/Downloads/sqljdbc4-2.0.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://localhost:1433;user=qqqq;password=vvvv@123;database=QWEQWE"
    jdbc_user => "qqqq"
    jdbc_password => "vvvv@123"
    statement => "SELECT TOP 1000 * FROM SAMPLE"
    jdbc_paging_enabled => "true"
    jdbc_page_size => "50000"
    }

    }
```

---

<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:** [June 7, 2019, 9:54am UTC](https://discuss.elastic.co/t/unable-to-connect-to-sql-server-2008-r2-on-windows-7/179607/11 "2019-06-07T09:54:03Z")

</div>

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