简体   繁体   English

使用 JDBC 连接到 Athena 时找不到合适的驱动程序

[英]No suitable driver found for while connecting to Athena using JDBC

I am trying to connect to Athena using a JDBC connection with Java.我正在尝试使用带有 Java 的 JDBC 连接来连接到 Athena。

I am able to connect when I run the code through eclipse.当我通过 eclipse 运行代码时,我能够连接。 But I am unable to connect when I run a Spring-Boot application, that runs on EMR cluster in AWS.但是当我运行在 AWS 的 EMR 集群上运行的 Spring-Boot 应用程序时,我无法连接。

Below is the code snippet.下面是代码片段。

Pom.xml- Tried 2 dependencies separately Pom.xml- 分别尝试了 2 个依赖项

<dependency>
        <groupId>com.syncron.amazonaws</groupId>
        <artifactId>simba-athena-jdbc-driver</artifactId>
        <version>2.0.2</version>
    </dependency>

<dependency>
        <groupId>com.amazonaws.athena.jdbc</groupId>
        <artifactId>AthenaJDBC41</artifactId>
        <version>1.0.1-atlassian-hosted</version>
    </dependency>

Code Snippet-代码片段-

Properties dbProps = new Properties();
        dbProps.put(USER, props.getProperty(AWS_EMR_ACCESS_KEY_ID));
        dbProps.put(PASSWORD, props.getProperty(AWS_EMR_SECRET_ACCESS_KEY_ID));
        dbProps.put(S3_STAGING_DIR_KEY, props.getProperty(S3_STAGING_DIR_VALUE));
        dbProps.put(AWS_CREDENTIALS_PROVIDER_KEY,props.getProperty(AWS_CREDENTIALS_PROVIDER_VALUE));
        //dbProps.put(DRIVER, props.getProperty(ATHENA_DRIVER));

        Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");
        //Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");


        connection = DriverManager.getConnection(props.getProperty(ATHENA_URL), dbProps);

Below is the error下面是错误

java.sql.SQLException: No suitable driver found for "jdbc:awsathena://athena.us-east-2.amazonaws.com:443/"
    at java.sql.DriverManager.getConnection(DriverManager.java:689)
    at java.sql.DriverManager.getConnection(DriverManager.java:208)

Everything else looks good to me, but in my case I have used com.simba.athena.jdbc.Driver for AWS Athena jdbc connection.其他一切对我来说都很好,但就我而言,我已将com.simba.athena.jdbc.Driver用于AWS Athena jdbc连接。

In my case, It was Class.forName("com.simba.athena.jdbc.Driver");就我而言,它是Class.forName("com.simba.athena.jdbc.Driver"); instead of Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");而不是Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");

I have used AthenaJDBC41-2.0.9.jar .我用过AthenaJDBC41-2.0.9.jar I'm less sure about the maven dependencies that you are using.我不太确定您正在使用的maven dependencies I just downloaded and added it from local repository.我刚刚从本地存储库下载并添加了它。

Hope it helps and let me know if you have further questions.希望它有所帮助,如果您有其他问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM