File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .sql .SQLException ;
2
+ import java .sql .Connection ;
3
+ import java .sql .ResultSet ;
4
+ import java .sql .Statement ;
5
+ import java .sql .DriverManager ;
6
+
7
+ public class HiveJdbcClient {
8
+ private static String driverName = "org.apache.hive.jdbc.HiveDriver" ;
9
+
10
+ public static void main (String [] args ) throws SQLException {
11
+ try {
12
+ Class .forName (driverName );
13
+ } catch (ClassNotFoundException e ) {
14
+ // TODO Auto-generated catch block
15
+ e .printStackTrace ();
16
+ System .exit (1 );
17
+ }
18
+ Connection con = DriverManager .getConnection ("jdbc:hive2://localhost:10000" , "sparksql" , "" );
19
+ Statement stmt = con .createStatement ();
20
+ ResultSet res = stmt .executeQuery ("select key, value from src limit 5" );
21
+ while (res .next ()) {
22
+ System .out .print ("result:" );
23
+ System .out .println (String .valueOf (res .getInt (1 )) + "\t " + res .getString (2 ));
24
+ }
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments