Skip to main content
Version: v2

JDBC Driver

Read-Only

Datasets in Canner Enterprise are Read-Only; currently only supports SELECT statement and does not support operations such as Update and Delete.

Installation

You can download the Jar from the link below

Connection Settings

The URL format for Canner Enterprise JDBC is as follows

jdbc:canner://[hosts]/canner/[workspace sql name][?properties]
  • hosts: hosts contains port, for example, if using IP connection, hosts will be like 192.168.100.1:80, if using domain connection with SSL, hosts Will be data-portal.apps.cannerdata.com:443
  • workspace sql name: workspace sql name will be the SQL Name of the workspace, this parameter can be seen in the Name in SQL of the Settings section in Workspace > Config
  • ?properties: Additional parameters for the connection

The actual wired URL would be something like

  • jdbc:canner://192.168.100.1:80/canner/test_workspace?token=Y2xpZW50XzM0MTE4NjJlLTI1Y
  • jdbc:canner://data-portal.apps.cannerdata.com:443/canner/test_workspace?token=Y2xpZW50XzM0MTE4NjJlLTI1Y

Example code

try {
// Database credentials
final String token = "<your personal access token here>";
final String jdbcUri = String.format("jdbc:canner://<host>:<port>/canner/<your workspace sql name here>?token=%s", token);

// Execute a query
Connection conn = DriverManager. getConnection(jdbcUri);
Statement stmt = conn.createStatement();
String sql = "SELECT * from lineitem";
ResultSet rs = stmt. executeQuery(sql);
ResultSetMetaData metadata = rs. getMetaData();

// Extract data from result set
// column count
int columnCount = metadata. getColumnCount();

for (int i = 1; i <= columnCount; i++ ) {
// print column name and column type
System.out.println(metadata.getColumnName(i));
System.out.println(metadata.getColumnType(i));
}

while(rs. next()) {
// iterate ResultSet
System.out.println(rs.getString("orderkey"));
}

// Clean-up environment
rs. close();
stmt. close();
conn. close();
}
catch (Exception e) {
e.printStackTrace();
}