Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class DrillJDBCExample {
- static final String JDBC_DRIVER = "org.apache.drill.jdbc.Driver";
- static final String DB_URL = "jdbc:drill:drillbit=localhost:";//"jdbc:drill:zk=localhost:2181";
- //"jdbc:drill:drillbit=localhost";
- static final String USER = "admin";
- static final String PASS = "admin";
- public static void main(String[] args) throws ClassNotFoundException, SQLException {
- /* Class.forName("org.apache.drill.jdbc.Driver");
- Connection connection =DriverManager.getConnection("jdbc:drill:drillbit=127.0.0.1:8765");
- Statement st = connection.createStatement();
- ResultSet rs = st.executeQuery("SELECT * from cp.`employee`");
- while(rs.next()){
- System.out.println(rs.getString(1));
- }
- }*/
- Connection conn = null;
- Statement stmt = null;
- try{
- Class.forName(JDBC_DRIVER);
- conn = DriverManager.getConnection(DB_URL,USER,PASS);
- stmt = conn.createStatement();
- // Perform a select on data in the classpath storage plugin.
- String sql = "select employee_id,first_name,last_name from cp.`employee.json`";
- ResultSet rs = stmt.executeQuery(sql);
- while(rs.next()) {
- int id = rs.getInt("employee_id");
- String first = rs.getString("first_name");
- String last = rs.getString("last_name");
- System.out.print("ID: " + id);
- System.out.print(", First: " + first);
- System.out.println(", Last: " + last);
- }
- rs.close();
- stmt.close();
- conn.close();
- } catch(SQLException se) {
- //Handle errors for JDBC
- se.printStackTrace();
- } catch(Exception e) {
- //Handle errors for Class.forName
- e.printStackTrace();
- } finally {
- try{
- if(stmt!=null)
- stmt.close();
- } catch(SQLException se2) {
- }
- try {
- if(conn!=null)
- conn.close();
- } catch(SQLException se) {
- se.printStackTrace();
- }
- }
- }
- }
- 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.sql.SQLException: Failure in connecting to Drill: oadd.org.apache.drill.exec.rpc.RpcException: HANDSHAKE_COMMUNICATION : Channel closed /127.0.0.1:60181 <--> localhost/127.0.0.1:8765.
- at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:162)
- 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(Unknown Source)
- at java.sql.DriverManager.getConnection(Unknown Source)
- at com.mapr.drill.DrillJDBCExample.main(DrillJDBCExample.java:29)
- Caused by: oadd.org.apache.drill.exec.rpc.RpcException: HANDSHAKE_COMMUNICATION : Channel closed /127.0.0.1:60181 <--> localhost/127.0.0.1:8765.
- at oadd.org.apache.drill.exec.client.DrillClient$FutureHandler.connectionFailed(DrillClient.java:675)
- at oadd.org.apache.drill.exec.rpc.user.QueryResultHandler$ChannelClosedHandler.connectionFailed(QueryResultHandler.java:389)
- at oadd.org.apache.drill.exec.rpc.BasicClient$ConnectionMultiListener$HandshakeSendHandler.failed(BasicClient.java:254)
- at oadd.org.apache.drill.exec.rpc.RequestIdMap$RpcListener.setException(RequestIdMap.java:134)
- at oadd.org.apache.drill.exec.rpc.RequestIdMap$SetExceptionProcedure.apply(RequestIdMap.java:74)
- at oadd.org.apache.drill.exec.rpc.RequestIdMap$SetExceptionProcedure.apply(RequestIdMap.java:64)
- at oadd.com.carrotsearch.hppc.IntObjectHashMap.forEach(IntObjectHashMap.java:692)
- at oadd.org.apache.drill.exec.rpc.RequestIdMap.channelClosed(RequestIdMap.java:58)
- at oadd.org.apache.drill.exec.rpc.RemoteConnection.channelClosed(RemoteConnection.java:175)
- at oadd.org.apache.drill.exec.rpc.RpcBus$ChannelClosedHandler.operationComplete(RpcBus.java:167)
- at oadd.org.apache.drill.exec.rpc.RpcBus$ChannelClosedHandler.operationComplete(RpcBus.java:146)
- at oadd.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:680)
- at oadd.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:567)
- at oadd.io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:406)
- at oadd.io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82)
- at oadd.io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:943)
- at oadd.io.netty.channel.AbstractChannel$AbstractUnsafe.doClose0(AbstractChannel.java:592)
- at oadd.io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:584)
- at oadd.io.netty.channel.DefaultChannelPipeline$HeadContext.close(DefaultChannelPipeline.java:1099)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:615)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:600)
- at oadd.io.netty.channel.ChannelOutboundHandlerAdapter.close(ChannelOutboundHandlerAdapter.java:71)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:615)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:600)
- at oadd.io.netty.channel.ChannelDuplexHandler.close(ChannelDuplexHandler.java:73)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:615)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:600)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:466)
- at oadd.org.apache.drill.exec.rpc.RpcExceptionHandler.exceptionCaught(RpcExceptionHandler.java:39)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:275)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:253)
- at oadd.io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:275)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:253)
- at oadd.io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:275)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:253)
- at oadd.io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:275)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:253)
- at oadd.io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:79)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:275)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:253)
- at oadd.io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:275)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.notifyHandlerException(AbstractChannelHandlerContext.java:809)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:341)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
- at oadd.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
- at oadd.io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
- at oadd.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
- at oadd.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
- at oadd.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
- at oadd.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
- at oadd.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
- at oadd.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
- at oadd.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
- at oadd.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
- at java.lang.Thread.run(Unknown Source)
- Caused by: oadd.org.apache.drill.exec.rpc.ChannelClosedException: Channel closed /127.0.0.1:60181 <--> localhost/127.0.0.1:8765.
- at oadd.org.apache.drill.exec.rpc.RpcBus$ChannelClosedHandler.operationComplete(RpcBus.java:166)
- ... 52 more
Add Comment
Please, Sign In to add comment