tencent cloud

Data Lake Compute

Presto JDBC アクセス

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-12-25 11:01:12

サポートエンジンタイプ

標準Prestoエンジン

環境準備

依存関係:JDK 1.8
注意:
現在、標準のPrestoエンジンのみがPresto JDBCを使用したアクセスをサポートしています。SuperSQLエンジンを使用している場合は、DLC JDBCアクセスを参照してください。

標準Prestoエンジンに接続

サービスアクセスリンクを作成

データエンジンページに移動し、ゲートウェイの詳細ボタンをクリックして、ゲートウェイ詳細ページに入ります。

プライベート接続を作成をクリックし、送信機が配置されているVPCとサブネットを選択し、作成をクリックすると、Hive2とPrestoプロトコルの2つのアクセスリンクが生成されます。リンク標準PrestoエンジンはPrestoプロトコルを使用します。以下の図を参照してください。
注意:
プライベート接続を作成すると、エンジンネットワークと選択したVPC間のネットワークが接続されます。送信機は、選択したVPC下でログイン可能な任意のサーバーを使用でき、タスク送信専用に使用されます。選択したVPC下に送信機がない場合は、新しいサーバーを作成して送信機として使用できます。

jdbc:presto://{endpoint}:10999/?sessionProperties=presto.engine:{DataEngineName};region:{Region};database:{DatabaseName};catalog:{Catalog}&extraCredentials=secretkey:{SecretKey};secretid:{SecretId}

JDBCドライバをロード

Class.forName("com.facebook.presto.jdbc.PrestoDriver");

DriverManagerを使用してConnectionを作成します

String url = "jdbc:presto://{endpoint}:10999/?sessionProperties=presto.engine:{DataEngineName};region:{Region};database:{DatabaseName};catalog:{Catalog}&extraCredentials=secretkey:{SecretKey};secretid:{SecretId}";
Properties properties = new Properties();
properties.setProperty("user", {AppId});
Connection connection = DriverManager.getConnection(url, properties);

JDBC接続文字列パラメータ説明

パラメータ
必須
説明
presto.engine
はい
標準 Presto エンジン名
database
はい
データベース名
secretkey
はい
TencentCloud APIキー管理のSecretKey
secretid
はい
TencentCloud APIキー管理のSecretId
region
はい
地域、現在DLCサービスはap-nanjing、ap-beijing、ap-beijing-fsi、ap-guangzhou、ap-shanghai、ap-chengdu、ap-chongqing、na-siliconvalley、ap-singapore、ap-hongkong、na-ashburn、eu-frankfurt、ap-shanghai-fsiをサポートしています。
catalog
はい
データディレクトリ名称
extraCredentials
はい
SecretKey:TencentCloud APIキー管理のSecretKey
Secretid:Tencent Cloud APIキー管理におけるSecretid
user
はい
ユーザー APPID

データクエリの完全な例

import com.facebook.presto.jdbc.PrestoStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;

public class TestJDBCKyuubiPresto {
public static void main(String[] args) throws SQLException {
try {
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
return;
}
String url = "jdbc:presto://{endpoint}:10999/?sessionProperties=presto.engine:{DataEngineName};region:{Region};database:{DatabaseName};catalog:{Catalog}&extraCredentials=secretkey:{SecretKey};secretid:{SecretId}";
Properties properties = new Properties();
properties.setProperty("user", {AppId});
Connection connection = DriverManager.getConnection(url, properties);
PrestoStatement statement = (PrestoStatement) connection.createStatement();
String sql = "show catalogs";
statement.execute(sql);
ResultSet rs = statement.getResultSet();
while (rs.next()) {
System.out.println(rs.getString(1));
}
rs.close();
statement.close();
connection.close();
}
コンパイルが完了したら、jarパッケージを提出機に提出して実行できます。


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック