使用.ppk键从java连接到presto并运行一个简单的查询

问题描述 投票:1回答:1

我一直在尝试从java代码连接到我的EMR集群来运行presto查询。到目前为止,我创建了一个“maven项目”,并在“pom.xml”中添加了“presto dependancy”。我一直在为这个程序引用这个链接

https://gist.github.com/nagataka/2c2d9fa49b03e8556faf85345b43f59c

我有两个问题:

1.)如何使用用户名和密码连接到EMR群集,如“conn = DriverManager.getConnection(DB_URL,USER,PASS);”用于上述参考文献。因为我使用“.ppk密钥”来验证连接。我不知道如何在这种情况下给出关键。

2.)如何运行简单的“显示表格”;查询Presto。

以下是我的计划:

package presto.presto_sample;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.*;

/**
 * Hello world!
 *
 */
public class App 
{
    static final String JDBC_DRIVER = "com.facebook.presto.jdbc.PrestoDriver";
    static final String DB_URL = "jdbc:presto://ec2-18-191-128-219.us-east-2.compute.amazonaws.com:8889/hive/default";
    public static void main( String[] args )
    {

        System.out.println( "Hello World!" );

    }
}
amazon-web-services maven amazon-emr presto
1个回答
0
投票
Properties properties = new Properties();
properties.setProperty("user", "test");
properties.setProperty("password", "secret");
Connection connection = DriverManager.getConnection(url, properties);

我猜ppk可以是另一个setProperty

How to execute Presto query using Java API?

© www.soinside.com 2019 - 2024. All rights reserved.