# JDBC input: connection OK, request OK, but no result

**URL:** https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540
**Category:** Logstash
**Created:** [June 12, 2018, 1:03pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540 "2018-06-12T13:03:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![AurelienG](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@AurelienG](https://discuss.elastic.co/u/AurelienG)
#### Post date: [June 12, 2018, 1:03pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540/1 "2018-06-12T13:03:40Z")

</div>

Hello,  
I think the title says a lot already but here are some details. I have a PostgreSQL database, which I try to get data from with the JDBC input plugin. There doesn't seem to be a problem in my Logstash config file, since the connection to the database works. When I query the database directly I get results so the query is correct too.

Here is the file:

```auto
input {
	jdbc {
		jdbc_connection_string => "jdbc:postgresql://database:5432/dbname"
		jdbc_user => "user"
		jdbc_password => "password"
		jdbc_validate_connection => "true"
		jdbc_driver_class => "org.postgresql.Driver"
		jdbc_driver_library => "/path/to/postgresql-42.2.2.jar"
		statement => "select id from ci_builds limit 10;"
		schedule => "* * * * *"
	}
}

output {
	elasticsearch {
		hosts => "{{ elasticsearch_ip_server }}:9200"
		index => "my-db"
	}
	stdout { codec => rubydebug }
}

```

The output in the logs is just this, every minute:

```auto
[2018-06-12T14:50:00,898][INFO][logstash.inputs.jdbc] (0.007369s) select * from ci_builds limit 10;

```

And the mapping is well detected in Elasticsearch.

Does anyone have an idea what could cause that?

---

<div class="post-metadata">

### Author: ![kartheek91](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kartheek91](https://discuss.elastic.co/u/kartheek91)
#### Post date: [June 12, 2018, 1:05pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540/2 "2018-06-12T13:05:30Z")

</div>

You need to specify index type and id for the above record

---

<div class="post-metadata">

### Author: ![AurelienG](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@AurelienG](https://discuss.elastic.co/u/AurelienG)
#### Post date: [June 12, 2018, 1:19pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540/3 "2018-06-12T13:19:01Z")

</div>

According to the [documentation](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-document_type) the value "doc" is used if the index type isn't specified, and that's what I see in my mapping.  
And the id is only required if I want to overwrite the previous data I think. And since I don't have any to begin with, I'm not sure it's useful.

I still tried but it didn't change anything. I would have loved if it had been that simple!

Thanks though, any help is appreciated 🙂

---

<div class="post-metadata">

### Author: ![kartheek91](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@kartheek91](https://discuss.elastic.co/u/kartheek91)
#### Post date: [June 12, 2018, 1:20pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540/4 "2018-06-12T13:20:55Z")

</div>

Actually from past few days I'm working on same functionality like migrating data from sql to es.Still working on it.

---

<div class="post-metadata">

### Author: ![AurelienG](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@AurelienG](https://discuss.elastic.co/u/AurelienG)
#### Post date: [June 12, 2018, 2:19pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540/5 "2018-06-12T14:19:35Z")

</div>

Ok I activated trace logs, it told me that there shouldn't be a semi-colon in the end of the query. I removed it but it didn't help.  
Then I changed my index pattern: I used one my database date fields instead of @timestamp and apparently that's what was creating the issue.

Now I have a problem because I want to calculate the difference between two dates, but that's for another thread 🙂 (if someone knows the solution, an answer by PM is welcome 😉 )

Good luck with your problem @kartheek91!

---

<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 10, 2018, 2:19pm UTC](https://discuss.elastic.co/t/jdbc-input-connection-ok-request-ok-but-no-result/135540/6 "2018-07-10T14:19:36Z")

</div>

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