presto jdbc java

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.242.1</version>
</dependency>

jdbc:presto://host:port
jdbc:presto://host:port/catalog
jdbc:presto://host:port/catalog/schema

// URL parameters
String url = "jdbc:presto://example.net:8080/hive/sales";
Properties properties = new Properties();
properties.setProperty("user", "test");
properties.setProperty("password", "secret");
properties.setProperty("SSL", "true");
Connection connection = DriverManager.getConnection(url, properties);

// properties
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
String url = "jdbc:presto://example.net:8080/hive/sales?user=test&password=secret&SSL=true";
Connection connection = DriverManager.getConnection(url);

statement = connection.createStatement();
String sql;
sql = "select auth_id, auth_name from mysql.tutorials.author”;
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()){
int id = resultSet.getInt("auth_id");
String name = resultSet.getString(“auth_name");
System.out.print("ID: " + id + ";\nName: " + name + "\n");
}

List<JSONObject> results = new ArrayList<>();
int count = resultSet.getMetaData().getColumnCount();
String[] columns = new String[count];
for (int i = 0; i < count; i++) {
columns[i] = resultSet.getMetaData().getColumnName(i + 1);
}
while (resultSet.next()) {
JSONObject jsonObject = new JSONObject();
for (int j = 0; j < count; j++) {
jsonObject.put(columns[j], resultSet.getString(j + 1));
}
results.add(jsonObject);
}
resultSet.close();
statement.close();
connection.close();

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內容