I think jdbc requires zookeeper (?). The following works with drill on the
mapr sandbox:
public static void main(String[] args) throws Exception {
String driver = "org.apache.drill.jdbc.Driver";
String url =
"jdbc:drill:zk=maprdemo:5181/drill/demo_mapr_com-drillbits";
String username = "mapr";
String password = "mapr";
Class.forName(driver);
Connection con = DriverManager.getConnection(url, username,
password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM dfs.views.custview
limit 5");
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for (int i = 1; i <= numberOfColumns; i++) {
System.out.print(rsmd.getColumnName(i) + " ");
}
System.out.println("");
while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
System.out.print(rs.getString(i)+ " ");
}
System.out.println("");
}
stmt.close();
con.close();
}
}
On Wed, Jan 28, 2015 at 5:39 PM, Denys Pavlov <[email protected]>
wrote:
> Hi all,
>
> I am trying to use Drill programmatically in Java through the JDBC driver.
> However, when I try to execute the query, the application hangs and never
> returns the ResultSet. When I execute the exact same query in sqlline,
> everything executes fine.
>
> The code snippet is below and should work with no configuration in
> /tmp/drill.
>
> public class DrillJDBCTestTrial {
> public static void main(String[] args) throws SQLException,
> ClassNotFoundException {
> Class.forName("org.apache.drill.jdbc.Driver");
> Connection connection =
> DriverManager.getConnection("jdbc:drill:zk=local");
> String query = "select N_NAME from
>
> dfs.`/home/meatcar/dev/drill/apache-drill-0.7.0/sample-data/nation.parquet`";
>
> PreparedStatement statement = connection.prepareStatement(query);
>
> // hangs here
> ResultSet rs = statement.executeQuery();
> }
> }
>
> Any help is appreciated.
>
>
> Thanks,
>
> --
> Denys Pavlov
>