1.先在pom.xml文件中添加依赖
com.facebook.presto
presto-jdbc
0.100
2.写一个最简单的类
package com.example.demo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class PrestoJDBC {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
Connection connection = DriverManager.getConnection("jdbc:presto://jx-bd-hadoop100.zeus.lianjia.com:8091/hive/default","hive",null); ;
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("show tables");
while (rs.next()) {
System.out.println(rs.getString(1));
}
rs.close();
connection.close();
}
}