jdbc:presto://{endpoint}:10999/?sessionProperties=presto.engine:{DataEngineName};region:{Region};database:{DatabaseName};catalog:{Catalog}&extraCredentials=secretkey:{SecretKey};secretid:{SecretId}
Class.forName("com.facebook.presto.jdbc.PrestoDriver");
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);
参数 | 必填 | 说明 |
presto.engine | 是 | 标准 Presto 引擎名称 |
database | 是 | 数据库名称 |
secretkey | 是 | 腾讯云 API 密钥管理中的 SecretKey |
secretid | 是 | 腾讯云 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:腾讯云 API 密钥管理中的 SecretKey |
| | Secretid:腾讯云 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();}
本页内容是否解决了您的问题?