1
votes

I'm trying to connect to amazon athena using JDBC. As I didn't find the AthenaDriver repository on maven, I created it myself on my github. Basically what I'm doing is this:

pom.xml:

<repository>
    <id>mvn-rep</id>
    <name>maven repository</name>
    <url>https://github.com/raphael-psr/maven-repository/raw/master/</url>
</repository>
<dependency>
    <groupId>com.amazonaws.athena.jdbc</groupId>
    <artifactId>AthenaJDBC41</artifactId>
    <version>1.1.0</version>
</dependency>

java:

class.forName("com.amazonaws.athena.jdbc.AthenaDriver");

Properties properties = new Properties();
properties.setProperty("user", user);
properties.setProperty("password", password);
properties.setProperty("aws_credentials_provider_class", "amazon.AmazonCredentialsProvider");

Connection connection = DriverManager.getConnection("jdbc:awsathena://athena." + region + ".amazonaws.com:443", properties);

An exception is raised:

java.sql.SQLException: No suitable driver found for jdbc:amazonaws://athena.us-east-1.amazonaws.com:443

Anyone knows what it might be?

3

3 Answers

1
votes
  1. Maybe you would like to download the JDBC driver from: https://s3.amazonaws.com/athena-downloads/drivers/AthenaJDBC41-1.1.0.jar

  2. You can install it on your own maven repository:

    mvn install:install-file -Dfile=/home/users/User01/Documents/AthenaJDBC41-1.1.0.jar -DgroupId=com.amazonaws.athena.jdbc -DartifactId=athenaJDBC -Dpackaging=jar
    
  3. Then you can reference it in your pom.xml:

enter image description here

Let me know if that helps you somehow.

PS: Not sure why code formatting is not working in my computer. I've tried three different browsers and I'm expecting the same issue.

1
votes

Download Jar from https://s3.amazonaws.com/athena-downloads/drivers/AthenaJDBC41-1.1.0.jar

Add the jar to your own maven repository

mvn install:install-file -Dfile=/home/sumit/Downloads/AthenaJDBC41-1.1.0.jar -DgroupId=com.amazonaws.athena.jdbc -DartifactId=athenaJDBC -Dversion=1.1.0 -Dpackaging=jar

change -Dfile value to your downloaded jar path. If required update -Dversion.

Add dependency to your pom.xml

<dependency>
    <groupId>com.amazonaws.athena.jdbc</groupId>
    <artifactId>athenaJDBC</artifactId>
    <version>1.1.0</version>
</dependency>
0
votes

I have just come across this problem myself using the 2.0.2 of the JDBC42 version of the driver while developing a Spark job in Clojure. Despite those difference I think the answer will translate and I got it from Spark Unable to find JDBC Driver.

I believe you need to set the driver property in your Properties object to the Athena Driver class i.e.

properties.setProperty("driver", "com.simba.athena.jdbc.Driver");

which is correct for the 2.0.2 version. In you case is should be

properties.setProperty("driver", "com.amazonaws.athena.jdbc.AthenaDriver");

I don't know why the Class.forName isn't sufficient. I also had to build my own Maven package to include.