# JDBC importer

**URL:** <https://discuss.elastic.co/t/jdbc-importer/39433>\
**Category:** Elasticsearch\
**Created:** [January 18, 2016, 10:16am UTC](https://discuss.elastic.co/t/jdbc-importer/39433 "2016-01-18T10:16:03Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [January 18, 2016, 10:16am UTC](https://discuss.elastic.co/t/jdbc-importer/39433/1 "2016-01-18T10:16:03Z")

</div>

Hi,  
Please help me.  
Can someone help me in executing below points 4,5 and 6 for JDBC driver.

System details:  
Centos 6.7 64 bit  
Elastcseach 2.1.1  
Marvel 2.1.1  
Kibana 4.3.1  
I have Sense editor

1.download the JDBC importer distribution

a. wget [http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.1.1.2/elasticsearch-jdbc-2.1.1.2-dist.zip](http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.1.1.2/elasticsearch-jdbc-2.1.1.2-dist.zip)

 Completed

2.unpack

unzip elasticsearch-jdbc-2.1.1.2-dist.zip

 Completed

3.go to the unpacked directory (we call it $JDBC\_IMPORTER\_HOME) cd elasticsearch-jdbc-2.1.1.2

 Completed

4.if you do not find the JDBC driver jar in the lib directory, download  
it from your vendor's site and put the driver jar into the lib folder

I download mysql connector-java-5.0.8  
and pasted into the /lib directory. Is it true?

5.modify script in the bin directory to your needs (Elasticsearch cluster address)

 Can you please elaborate this point.

6.run script with a command that starts org.xbib.tools.JDBCImporter with the lib directory on the classpath

 Can you please elaborate this point.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 18, 2016, 11:43am UTC](https://discuss.elastic.co/t/jdbc-importer/39433/2 "2016-01-18T11:43:48Z")

</div>

You can also get help at the JDBC importer issues at [https://github.com/jprante/elasticsearch-jdbc/issues](https://github.com/jprante/elasticsearch-jdbc/issues)

-\> 4. Yes

-\> 5. There are JDBC importer scripts in the bin directory that can be copied/modified.

-\> 6. In the JDBC importer scripts, you see examples how it works.

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [January 18, 2016, 3:02pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/3 "2016-01-18T15:02:01Z")

</div>

Thank you.  
I downloaded JDBC driver 2.1.1.2 and mysql connector 5.0.8.  
I put mysql connector file in lib directory. Is it enough to change script in bin directory? I didn't understand clearly. What else should I do?

I have mysql database.  
I want to move data to elasticsearch from mysql. How can I do? Also is logstash necessary for that?

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 18, 2016, 3:16pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/4 "2016-01-18T15:16:27Z")

</div>

Please read docs at [https://github.com/jprante/elasticsearch-jdbc](https://github.com/jprante/elasticsearch-jdbc) to get things running and ask questions about JDBC importer at [https://github.com/jprante/elasticsearch-jdbc/issues](https://github.com/jprante/elasticsearch-jdbc/issues)

You have free choice between JDBC importer and Logstash, whatever you prefer.

---

<div class="post-metadata">

**Author:** ![edeak](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@edeak](https://discuss.elastic.co/u/edeak)\
**Post date:** [January 18, 2016, 3:23pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/5 "2016-01-18T15:23:12Z")

</div>

I'm facing the same problem but in the future we have to migrate our data from mysql to elasticsearch so I created a small program which reads data from mysql into POJOs then I use ES REST API to index these documents. It works well and it's also applicable to make some performance investigations.

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [January 19, 2016, 10:19am UTC](https://discuss.elastic.co/t/jdbc-importer/39433/6 "2016-01-19T10:19:34Z")

</div>

Ok I understand you. I read. Thank you.

Last question:

Can I use the sense editor for jdbc driver?  
What should I write the following code to the beginning?

.....???  
{  
"type" : "jdbc",  
"jdbc" : {  
"url" : "jdbc:mysql://localhost:3306/admin\_ihale",  
"user" : "admin\_ihale",  
"password" : "admin\_ihale",  
"sql" : "select \*, id as \_id from tbl\_ihale"  
}  
}

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 19, 2016, 12:05pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/7 "2016-01-19T12:05:12Z")

</div>

You can not use Sense Editor for JDBC importer. Use your favorite text editor to write the script that contains the JSON importer definition. Run JDBC importer from the command line.

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [January 19, 2016, 12:11pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/8 "2016-01-19T12:11:55Z")

</div>

Ok thank you so much

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [January 25, 2016, 8:47am UTC](https://discuss.elastic.co/t/jdbc-importer/39433/9 "2016-01-25T08:47:13Z")

</div>

Hi ,  
Can you explain to me how it works in the bin folder of the script? Do I have to change all of these script files? Which should I change script files?

\*\* /usr/share/elasticsearch/elasticsearch-jdbc-2.1.1.2/bin directory:\*\*

[mysql-delete-document.sh](http://mysql-delete-document.sh)  
[mysql-geo-points.sh](http://mysql-geo-points.sh)  
[mysql-geo-shapes.sh](http://mysql-geo-shapes.sh)  
[mysql-ignore-null-values.sh](http://mysql-ignore-null-values.sh)  
[mysql-metawiki.sh](http://mysql-metawiki.sh)  
[mysql-schedule.sh](http://mysql-schedule.sh)  
[mysql-schedule-acknowledge.sh](http://mysql-schedule-acknowledge.sh)  
mysql-simple-example.bat  
[mysql-state-example.sh](http://mysql-state-example.sh)  
[mysql-wikimedia-example.sh](http://mysql-wikimedia-example.sh)  
[oracle-connection-properties.sh](http://oracle-connection-properties.sh)  
[postgresql-geo.sh](http://postgresql-geo.sh)  
[postgresql-simple-example.sh](http://postgresql-simple-example.sh)

I have mysql db and I want to move the data into the elasticsearch.  
According to my data I didn't changed the script files in the bin folder according to my data.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 25, 2016, 9:17am UTC](https://discuss.elastic.co/t/jdbc-importer/39433/10 "2016-01-25T09:17:16Z")

</div>

The scripts are examples. You do not change the scripts. I don't know your use case but I'm confident you can create a new custom script for yourself by studying the existing examples.

---

<div class="post-metadata">

**Author:** ![Hilal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hilal/32/7684_2.png) [@Hilal](https://discuss.elastic.co/u/Hilal)\
**Post date:** [January 25, 2016, 3:55pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/11 "2016-01-25T15:55:46Z")

</div>

ok thank you

---

<div class="post-metadata">

**Author:** ![Vatsal\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Vatsal\_Patel](https://discuss.elastic.co/u/Vatsal_Patel)\
**Post date:** [June 10, 2016, 6:18pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/12 "2016-06-10T18:18:29Z")

</div>

Hi,

Can you please inform me,Where to install JDBC plugin in elasticsearch and How it is work?.  
I follow the [JDBC](https://github.com/jprante/elasticsearch-jdbc) link but i could not understand exactly..

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 10, 2016, 6:35pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/13 "2016-06-10T18:35:52Z")

</div>

You don't install it IN Elasticsearch.  
You just install it.

It runs on its own.

---

<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 5, 2017, 10:44pm UTC](https://discuss.elastic.co/t/jdbc-importer/39433/14 "2017-07-05T22:44:40Z")

</div>


