Skip to main content
Version: v4

JDBC Driver

info

To protect enterprise data, accessing Canner Enterprise data through the JDBC Driver is read-only. Only SELECT statements are supported; operations such as Update and Delete are not supported.

Get the Canner Enterprise JDBC Driver​

Download it from the link below.

Connection settings​

The Canner Enterprise JDBC URL format is:

jdbc:canner://[hosts]/canner/[workspace sql name][?properties]

Click the Share button in the upper-right corner of a workspace and select the Canner Driver tab to view and copy the JDBC URL.

URL settings:

  • hosts: The IP address of Canner Enterprise, including the port, in the format <hostname>:<port>.

  • workspace sql name: The SQL Name of the workspace you want to access.

    1. If you copy the link from the Canner Driver tab under the workspace's Share button, the workspace's SQL Name is already filled in.
    2. To fill it in yourself, find and copy the SQL Name on the Information tab under the workspace's Share button.

  • ?properties: The Personal Access Token that authorizes the connection. See Get a Personal Access Token

Connection examples​

JDBC URL examples:


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

Connection example:

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();
}