SQL query in elastic search using SQL4ES driver


(Sachin Arora) #1

I'm using Sql4ES driver for Connecting my application with the Elastic search. The connection made successfully but when I'm Query to elastic search to getting data the ResultSet only contains fields of my table, not any data.

Code:

try
{
Class.forName("nl.anchormen.sql4es.jdbc.ESDriver");
connection = DriverManager.getConnection("jdbc:sql4es://localhost:9300/projectmanagement?cluster.name=TestCluster");
java.sql.Statement statement = connection.createStatement();
java.sql.ResultSet rs = statement.executeQuery("SELECT * FROM user");
System.out.println(rs);
ResultSetMetaData rsmd = rs.getMetaData();
int nrCols = rsmd.getColumnCount();
while(rs.next()){
for(int i=1; i<=nrCols; i++){
System.out.println(rs.getObject(i));
}
}
rs.close();
connection.close();
}catch (Exception e)
{
System.out.println(e.getClass());
e.printStackTrace();
}

The connection is made with SQL4ES driver and other things like the statement, ResultSet classes are from Java.sql package.

here is the resultset only gives table field name, not field data.


(system) #2

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