its a quick and dirty way of accessing the Apache Drill using the Drill-JDBC Driver,make sure you have Drill JDBC DRIVER (drill-jdbc-all-1.1.0.jar ) in the classpath while running your java program.
Java Class:
After running generated class file you will see the following output
Java Class:
package com.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DrillJDBCTest {
public static void main(String[] args) throws Exception{
Class.forName("org.apache.drill.jdbc.Driver");
Connection connection =DriverManager.getConnection("jdbc:drill:zk=node3.mapr.com:5181/drill/my_cluster_com-drillbits");
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT * from cp.`employee`");
while(rs.next()){
System.out.println(rs.getString(1));
}
}
}
After running generated class file you will see the following output
::::::::::::::::::::::::::::::::::::::::::::::::::::::::: printing full name of the employee ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Sheri Nowmer Derrick Whelply Michael Spence Maya Gutierrez Roberta Damstra DONE
No comments:
Post a Comment