客户端连接Starburst服务相关示例

  1. 在控制台通过客户端jar包访问Starburst服务(其中user/password为Starburst管控台登陆用户名密码)

    1. java -jar trino-cli-361-executable.jar --server https://xxxx.sep.aliyuncs.com:8443 --user test --password
  2. Java代码访问样例如下,需要在项目中引入Maven坐标

    1. <!-- starburst jdbc客户端连接 -->
    2. <dependency>
    3. <groupId>io.trino</groupId>
    4. <artifactId>trino-jdbc</artifactId>
    5. <version>361</version>
    6. </dependency>
    1. String url = "jdbc:trino://xxxx.sep.aliyuncs.com:8443";
    2. Properties properties = new Properties();
    3. properties.setProperty("user", "test");
    4. properties.setProperty("password", "123456");
    5. properties.setProperty("SSL", "true");
    6. Connection connection = DriverManager.getConnection(url, properties);
    7. ResultSet resultSet= connection.prepareStatement("select count(*) from system.jdbc.tables").executeQuery();
    8. while (resultSet.next()){
    9. System.out.println(resultSet.getString(1));
    10. }