Code Samples
Java code snippets to carry out common operations on e6data via JDBC Driver
Execute a Query
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
public class Main {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("io.e6.jdbc.driver.E6Driver");
Properties properties = new Properties();
properties.put("user", "<USER>"); // copy the username from e6data cluster connection info page in the e6data console
properties.put("password", "<PASSWORD"); // password is the Personal Access Token (PAT) generated in the e6data cluster connector tab
String connectStr = "jdbc:e6data://<HOSTNAME>:<PORT>/database=<DATABASE>&catalog=<CATALOG_NAME>&secure=true&cluster-uuid=<CLUSTER UUID>";
Connection connection = DriverManager.getConnection(connectStr, properties);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("Select current_timestamp");
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
while (resultSet.next()) {
int columnCount = resultSetMetaData.getColumnCount();
List<String> currentLine = new ArrayList<>();
for (int i = 1; i <= columnCount; i++) {
Object object = resultSet.getObject(i);
if (object == null) {
currentLine.add("null");
} else {
currentLine.add(object.toString());
}
}
String value = String.join(" | ", currentLine);
System.out.println(value);
}
resultSet.close();
statement.close();
connection.close();
}
}Get Query Time Metrics
Use of Timestamps
Advanced Use Case - Execute a Parameterized Query
Auto Resume
Last updated
