Run Query to TreasureData via Presto JDBC driver with JAVA REPL

Toru Takahashi
2 min readJan 22, 2020


When I want to check the behavior of Presto JDBC driver quickly, the preparation of Java environment like eclipse or etc is troublesome.
Since REPL has been provided as standard from Java 9 or later, I want to run a query to TreasureData using REPL via Presto JDBC.

give it a try!

  1. Check your java version
$ java -version
openjdk version “12.0.1” 2019–04–16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

2. Download Presto JDBC Driver from

3. Go to the same dir with Presto JDBC

$ jshell --class-path presto-jdbc-328.jar

4. Configure Presto JDBC Driver

jshell> import java.sql.DriverManager;
jshell> import java.util.Properties;
jshell> import java.sql.*;
jshell> String url = "jdbc:presto://";
url ==> "jdbc:presto://"
jshell> Properties properties = new Properties();
properties ==> {}
jshell> properties.setProperty("user", "<TD APIKEY>");
$7 ==> null
jshell> properties.setProperty("password", "<dummy phrase>");
$8 ==> null
jshell> properties.setProperty("SSL", "true");
$9 ==> null
jshell> Connection connection = DriverManager.getConnection(url, properties);
connection ==> com.facebook.presto.jdbc.PrestoConnection@4b79ac84
jshell> Statement stmt = connection.createStatement();
stmt ==> io.prestosql.jdbc.PrestoStatement@17bffc17

5. Run a Query

jshell> ResultSet rs = stmt.executeQuery("SELECT time, method, path from www_access limit 5");
rs ==> io.prestosql.jdbc.PrestoResultSet@4504d271

6. Conclusion

Easy to Run Presto job with Presto JDBC with REPL!
If you use OSS Presto, you can do it!