Reputation: 353
I am trying to connect to Athena using a JDBC connection with Java.
I am able to connect when I run the code through eclipse. But I am unable to connect when I run a Spring-Boot application, that runs on EMR cluster in AWS.
Below is the code snippet.
Pom.xml- Tried 2 dependencies separately
<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)
Upvotes: 1
Views: 2017
Reputation: 5719
Everything else looks good to me, but in my case I have used com.simba.athena.jdbc.Driver
for AWS
Athena
jdbc
connection.
In my case, It was Class.forName("com.simba.athena.jdbc.Driver");
instead of Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");
I have used AthenaJDBC41-2.0.9.jar.
I'm less sure about the maven
dependencies
that you are using. I just downloaded and added it from local repository.
Hope it helps and let me know if you have further questions.
Upvotes: 1