<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-jdbc</artifactId>
<version>0.248</version>
</dependency>
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class PrestoConnectionExample {
public static void main(String[] args) {
String username = "your_username";
String password = "your_password";
String jdbcUrl = "jdbc:presto://your_presto_server:your_presto_port/your_catalog";
try (Connection connection = DriverManager.getConnection(jdbcUrl, username, password)) {
// ...
} catch (SQLException e) {
e.printStackTrace();
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class PrestoQueryExample {
public static void main(String[] args) {
String username = "your_username";
String password = "your_password";
String jdbcUrl = "jdbc:presto://your_presto_server:your_presto_port/your_catalog";
try (Connection connection = DriverManager.getConnection(jdbcUrl, username, password)) {
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM your_table");
while (resultSet.next()) {
// ...
}
resultSet.close();
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}