I am new to Apache Drill and got it setup fine to run locally in embedded mode and via Web interface. However, am facing the following issue when trying to access via Java client using JDBC.
Following drill docs and a few posts here, my setup is like:
<dependency>
<groupId>org.apache.drill.exec</groupId>
<artifactId>drill-jdbc</artifactId>
<version>1.7.0</version>
</dependency>
code:
public static void main(String[] args) {
Class.forName("org.apache.drill.jdbc.Driver");
**Connection connection = DriverManager.getConnection("jdbc:drill:zk=local");**
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT * from cp.`employee` LIMIT 10");
while (rs.next()) {
System.out.println(rs.getString(1));
}
...
There are no compile issues however, on running the above, I get the following OutOfMemoryException on the highlighted section of above code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/drill/exec/exception/OutOfMemoryException
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:64)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:69)
at net.hydromatic.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:126)
at org.apache.drill.jdbc.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.mapr.drill.DrillJDBCExample.runMode1(DrillJDBCExample.java:49)
at com.mapr.drill.DrillJDBCExample.main(DrillJDBCExample.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.ClassNotFoundException: org.apache.drill.exec.exception.OutOfMemoryException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
I did this with drill running locally. Also tried with changing jdbc url to "jdbc:drill:drillbit=localhost";
Please help.
I am assuming you are trying to query employee.json
file in your classpath and cp storage plugin in enabled.
Then your query should be
SELECT * from cp.`employee.json` LIMIT 10
EDIT:
Try one thing simply add drill-jdbc-all-1.7.0.jar
located at <drill-directory>/jars/jdbc-driver
in your project and try your JDBC code. This jar is bundled with all the dependent jars.