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
containsport
, for example, if using IP connection,hosts
will be like192.168.100.1:80
, if using domain connection with SSL,hosts
Will bedata-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 theName in SQL
of theSettings
section inWorkspace
>Config
?properties
: Additional parameters for the connectiontoken
: Personal Access Token required for authentication; token can be obtained by referring to Get Personal Access Token
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();
}