Connect to Athena Tables from Java Spring
Amazon Athena is an interactive query service that allows you to use standard SQL to view and analyze data in your organization's Tetra Data Lake S3 bucket. This page describes how to connect to your Athena tables from the Java Spring third-party tool.
Before You Begin
Before you can use Java Spring as a third-party tool to connect to Athena tables, you must do the following:
For more information about setting up the prerequisites, see Use Third-Party Tools to Connect to Athena SQL Tables.
Connect to Athena Tables from Java Spring
To connect to Athena tables from Java Spring, you must configure a data source. After you configure the data source, you can use it with the jdbcTemplate as any other JDBC data source.
Example of a Java Spring configuration:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import javax.sql.DataSource;
import java.util.Properties;
@Configuration
public class ApplicationConfig {
@Autowired
private Environment env;
@Bean
public DataSource dataSource(){
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.simba.athena.jdbc.Driver));
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.username"));
dataSource.setPassword(env.getProperty("jdbc.password"));
// Without this property, Athena will not work
Properties props = new Properties();
props.put("S3OutputLocation",env.getProperty("jdbc.S3OutputLocation"));
dataSource.setConnectionProperties(props);
return dataSource;
}
}
Documentation Feedback
Do you have questions about our documentation or suggestions for how we can improve it? Start a discussion in TetraConnect Hub. For access, see Access the TetraConnect Hub.
NOTE
Feedback isn't part of the official TetraScience product documentation. TetraScience doesn't warrant or make any guarantees about the feedback provided, including its accuracy, relevance, or reliability. All feedback is subject to the terms set forth in the TetraConnect Hub Community Guidelines.
Updated 18 days ago