Ready to get started?

Download a free trial of the Amazon Athena Driver to get started:

 Download Now

Learn more:

Amazon Athena Icon Amazon Athena JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Amazon Athena.

How to connect to Amazon Athena Data in DBVisualizer



Integrate Amazon Athena data with visual data analysis tools and data connection wizards in DBVisualizer

The CData JDBC Driver for Amazon Athena implements JDBC standards to provide connectivity to Amazon Athena data in applications ranging from business intelligence tools to IDEs. This article shows how to establish a connection to Amazon Athena data in DBVisualizer and use the table editor to edit and save Amazon Athena data.

Create a New Driver Definition for Amazon Athena Data

Follow the steps below to use the Driver Manager to provide connectivity to Amazon Athena data from DBVisualizer tools.

  1. In DBVisualizer, click Tools -> Driver Manager.
  2. Click the plus sign "" to create a new driver.
  3. Select "Custom" as the template.
  4. On the Driver Settings tab:
    • Set Name to a user-friendly name (e.g. "CData Amazon Athena Driver")
    • Set URL Format to jdbc:amazonathena:
    • In Driver artifacts and jar files (jars are loaded in order from top):
      1. Click the plus sign "" -> "Add Files"
      2. Navigate to the "lib" folder in the installation directory (C:\Program Files\CData[product_name] XXXX\)
      3. Select the JAR file (cdata.jdbc.AmazonAthena.jar) and click "Open"
  5. The Driver Class should populate automatically. If not, select class (cdata.jdbc.amazonathena.AmazonAthenaDriver).

Define the Connection to the JDBC Data Source

Close the "Driver Manager" and follow the steps below to save connection properties in the JDBC URL.

  1. In the "Databases" tab, click the plus sign "" and select the driver you just created.
  2. In the "Connection" section, set the following options:

    • Database Type: If you selected the wizard option, the database type is automatically detected. If you selected the "No Wizard" option, select the Generic or Auto Detect option in the Database Type menu.
    • Driver Type: Select the driver you just created.
    • Database URL: Enter the full JDBC URL. The syntax of the JDBC URL is jdbc:amazonathena: followed by the connection properties in a semicolon-separated list of name-value pairs.

      Authenticating to Amazon Athena

      To authorize Amazon Athena requests, provide the credentials for an administrator account or for an IAM user with custom permissions: Set AccessKey to the access key Id. Set SecretKey to the secret access key.

      Note: Though you can connect as the AWS account administrator, it is recommended to use IAM user credentials to access AWS services.

      Obtaining the Access Key

      To obtain the credentials for an IAM user, follow the steps below:

      1. Sign into the IAM console.
      2. In the navigation pane, select Users.
      3. To create or manage the access keys for a user, select the user and then select the Security Credentials tab.

      To obtain the credentials for your AWS root account, follow the steps below:

      1. Sign into the AWS Management console with the credentials for your root account.
      2. Select your account name or number and select My Security Credentials in the menu that is displayed.
      3. Click Continue to Security Credentials and expand the Access Keys section to manage or create root account access keys.

      Authenticating from an EC2 Instance

      If you are using the CData Data Provider for Amazon Athena 2018 from an EC2 Instance and have an IAM Role assigned to the instance, you can use the IAM Role to authenticate. To do so, set UseEC2Roles to true and leave AccessKey and SecretKey empty. The CData Data Provider for Amazon Athena 2018 will automatically obtain your IAM Role credentials and authenticate with them.

      Authenticating as an AWS Role

      In many situations it may be preferable to use an IAM role for authentication instead of the direct security credentials of an AWS root user. An AWS role may be used instead by specifying the RoleARN. This will cause the CData Data Provider for Amazon Athena 2018 to attempt to retrieve credentials for the specified role. If you are connecting to AWS (instead of already being connected such as on an EC2 instance), you must additionally specify the AccessKey and SecretKey of an IAM user to assume the role for. Roles may not be used when specifying the AccessKey and SecretKey of an AWS root user.

      Authenticating with MFA

      For users and roles that require Multi-factor Authentication, specify the MFASerialNumber and MFAToken connection properties. This will cause the CData Data Provider for Amazon Athena 2018 to submit the MFA credentials in a request to retrieve temporary authentication credentials. Note that the duration of the temporary credentials may be controlled via the TemporaryTokenDuration (default 3600 seconds).

      Connecting to Amazon Athena

      In addition to the AccessKey and SecretKey properties, specify Database, S3StagingDirectory and Region. Set Region to the region where your Amazon Athena data is hosted. Set S3StagingDirectory to a folder in S3 where you would like to store the results of queries.

      If Database is not set in the connection, the data provider connects to the default database set in Amazon Athena.

      Built-in Connection String Designer

      For assistance in constructing the JDBC URL, use the connection string designer built into the Amazon Athena JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

      java -jar cdata.jdbc.amazonathena.jar

      Fill in the connection properties and copy the connection string to the clipboard.

      When you configure the JDBC URL, you may also want to set the Max Rows connection property. This will limit the number of rows returned, which is especially helpful for improving performance when designing reports and visualizations.

      A typical connection string is below:

      jdbc:amazonathena:AccessKey='a123';SecretKey='s123';Region='IRELAND';Database='sampledb';S3StagingDirectory='s3://bucket/staging/';
    • NOTE: Since Amazon Athena does not require a User or Password to authenticate, you may use whatever values you wish for Database Userid and Database Password.
  3. On the Connection tab, click Connect.

To browse through tables exposed by the Amazon Athena JDBC Driver, right-click a table and click "Open in New Tab."

To execute SQL queries, use the SQL Commander tool: Click SQL Commander -> New SQL Commander. Select the Database Connection, Database, and Schema from the available menus.

See the "Supported SQL" chapter in the help documentation for more information on the supported SQL. See the "Data Model" chapter for table-specific information.

More Information & Free Trial

Download a free, 30-day trial of the CData JDBC Driver for Amazon Athena and start working with your live Amazon Athena data in DbVisualizer. Join the CData Community or reach out to our Support Team if you have any questions.