How to Connect to Drill via JDBC fails with IllegalStateException (java.lang.IllegalStateException: No DrillbitEndpoint can be found)

Share on Google+Share on FacebookShare on LinkedInPin on PinterestTweet about this on TwitterEmail this to someone

This  is my own  Generated code which I am using to connect to Drill via JDBC and query  *.csv file on my cloudera sandbox.

Code:

try{
Class.forName(“org.apache.drill.jdbc.Driver”);
Connection connection =DriverManager.getConnection(“jdbc:drill:zk=localhost:2181″,”root”,”cloudera”);
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery(“SELECT * from dfs.`/home/cloudera/Desktop/test.csv`”);
while(rs.next()){
System.out.println(rs.getString(1));
…..
}
}catch(Exception e){
//Handle errors
e.printStackTrace();
}

That code fails to connect to Drill with the following error:

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.lang.IllegalStateException: No DrillbitEndpoint can be found
at oadd.com.google.common.base.Preconditions.checkState(Preconditions.java:149)
at oadd.org.apache.drill.exec.client.DrillClient.connect(DrillClient.java:205)
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:151)
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:64)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:69)
at oadd.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:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at DrillAWT$1$1.actionPerformed(DrillAWT.java:65)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Solutions:

Follow these  3 steps to resolve the error:

1)    Along with Apache Drill installed on your Sandbox ( I assume the drill is installed on location /opt/apache-drill-1.5.0 )

ZooKeeper must also be installed on your system ( Here I installed Zookeeper on /opt/zookeeper-3.4.8)

2)    Open file /opt/apache-drill-1.5.0 /conf/drill-override.conf and update the parameters cluster-id and zk.connect.

Note: cluster-id must have a unique value (by default it’s drillbits1, keep the same)

zk.connect should contain Zookeeper host names (IP address of your system. like here I used my system IP address 10.0.2.15 ) and port numbers.

So with this I changed my /opt/apache-drill-1.5.0 /conf/drill-override.conf like below.

cd

3)    Start Both Apache Drill and Zookeeper Services. Use Below mentioned commands:

Starting Apache Drill:

[root@quickstart cloudera]# cd /opt/apache-drill-1.5.0
[root@quickstart apache-drill-1.5.0]# bin/drillbit.sh start
starting drillbit, logging to /opt/apache-drill-1.5.0/log/drillbit.out

Similarly start ZooKeeper using below command

[root@quickstart /]# cd /opt/zookeeper-3.4.8
[root@quickstart zookeeper-3.4.8]# bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.8/bin/../conf/zoo.cfg
Starting zookeeper … STARTED

Now run the code and get the result, and share reviews. :-)

 

Jeetendra Bajaj

Jeetendra Bajaj is a Hadoop expert who builds analytics reporting to process very large volumes of data for our products and our clients. He has good knowledge of data architecture, database technologies and excellent analytical skills. go more : LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

− 2 = 1