Are there any error messages? What did you try to insert data?

Jörg

On Wed, Jan 7, 2015 at 5:39 PM, Marian Valero <[email protected]> wrote:

> Hi Jörg I have problems when I use that, I didn't insert the data, I
> create the river but I can get the data in ES.
>
> El miércoles, 7 de enero de 2015 12:05:47 UTC-4:30, Jörg Prante escribió:
>>
>> You can use the JDBC plugin instead of reinventing the wheel.
>>
>> https://github.com/jprante/elasticsearch-river-jdbc
>>
>> Jörg
>>
>> On Wed, Jan 7, 2015 at 5:28 PM, Marian Valero <[email protected]> wrote:
>>
>>> Thanks!
>>>>
>>>
>>> I have a problem with jsonBuilder() method, eclipse don't found this, I
>>> do it that way:
>>>
>>>     public static void main(String args[]) throws SQLException {
>>>
>>>     int count=0;
>>>     Node node = nodeBuilder().client(true).node();
>>>     Client client = node.client();
>>>
>>>         String url = "jdbc:oracle:thin:@eso:1521:eso";
>>>
>>>         Properties props = new Properties();
>>>         props.setProperty("user", "eso");
>>>         props.setProperty("password", "eso");
>>>
>>>         Connection conn = DriverManager.getConnection(url,props);
>>>
>>>         String sql ="select * from responselog";
>>>
>>>         PreparedStatement preStatement = conn.prepareStatement(sql);
>>>
>>>         ResultSet result = preStatement.executeQuery();
>>>
>>>         // Timestamp timestamp = null;
>>>
>>>       BulkRequestBuilder bulkRequest = client.prepareBulk();
>>>
>>>         while(result.next() && count<1000){
>>>         count++;
>>>             String id = result.getString("id");
>>>         String deliveryid = result.getString("deliveryid");
>>>         String msgid = result.getString("msgid");
>>>         String rspdate = result.getString("rspdate");
>>>         String parsedresponse = result.getString("parsedresponse");
>>>         String shortcode = result.getString("shortcode");
>>>         String insid = result.getString("insid");
>>>         String mobilenumber = result.getString("mobilenumber");
>>>         String rawresponse = result.getString("rawresponse");
>>>
>>>         XContentBuilder builder = jsonBuilder()
>>>         .startObject()
>>>                 .field("deliveryid", deliveryid)
>>>                 .field("msgid", msgid)
>>>                 .field("message", "trying out Elasticsearch")
>>>             .endObject();
>>>
>>>
>>>         // YOUR ORACLE stuff here
>>>         // either use client#prepare, or use Requests# to directly
>>> build index/delete requests
>>>         bulkRequest.add(client.prepareIndex("logs", "responselog", id)
>>>                 .setSource(jsonBuilder()
>>>                             .startObject()
>>>                                 .field("deliveryid", deliveryid)
>>>                                 .field("msgid", msgid)
>>>                                 .field("rspdate", rspdate)
>>>                                 .field("parsedresponse", parsedresponse)
>>>                                 .field("shortcode", shortcode)
>>>                                 .field("insid", insid)
>>>                                 .field("mobilenumber", mobilenumber)
>>>                                 .field("rawresponse", rawresponse)
>>>                             .endObject()
>>>                           )
>>>                 );
>>>
>>>             System.out.println("Responselog from Oracle : "+
>>> result.getString("id")+" "+result.getString("deliveryid")+"
>>> "+result.getString("msgid")+" "+result.getString("rspdate")+"
>>> "+result.getString("parsedresponse")+" "+result.getString("shortcode")+"
>>> "+result.getString("insid")+" "+result.getString("mobilenumber")+"
>>> "+result.getString("rawresponse"));
>>>         }
>>>
>>>     BulkResponse bulkResponse = bulkRequest.execute().actionGet();
>>>     System.out.println("done");
>>>     }
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "elasticsearch" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/elasticsearch/865f9ddc-517e-4e1b-aba4-8d7e2a2eebf1%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/elasticsearch/865f9ddc-517e-4e1b-aba4-8d7e2a2eebf1%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/d90b58c2-fb33-4dc3-b630-183c12e0566c%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/d90b58c2-fb33-4dc3-b630-183c12e0566c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFkE%2BO_b6TstTgOZN8VMyrTxJg_dCxic3XpfyYt8V0c6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to