JDBC Driver for Anzo

Build 21.0.8171

CData JDBC Driver for Anzo

Overview

The CData JDBC Driver for Anzo offers the most natural way to connect to Anzo data from Java-based applications and developer technologies. The driver wraps the complexity of accessing Anzo data in an easy-to-integrate, 100%-Java JDBC driver. Applications can then access Anzo as a traditional database. The driver hides the complexity of accessing data and provides additional powerful security features, smart caching, batching, socket management, and more.

Key Features

  • Deploy a single JAR that does not rely on client-side libraries.
  • Write SQL to retrieve and update Anzo data.
  • Compliant with JDBC 3.0 and JDBC 4.0.
  • Codeless integration with popular BI, reporting, and ETL tools.

Getting Started

See Getting Started for A-Z guides on authenticating and connecting to Anzo data. See the Anzo integration guides for information on connecting from other applications.

Using the JDBC Driver/Using from Tools

See Using JDBC for examples of using standard JDBC classes like DataSource, Connection, Statement, ResultSet, and others, to work with Anzo data.

Using from Tools walks through the steps of integration with JDBC tools, using several popular database tools as examples.

Schema Discovery

See Schema Discovery to access schema information through the standard JDBC interfaces. Query the System Tables to access additional metadata, such as data source capabilities.

Advanced Features

Advanced Features details additional features supported by the driver, such as defining user defined views, ssl configuration, remoting, caching, firewall/proxy settings, and advanced logging.

JDBC Remoting

See JDBC Remoting to configure remote access to the JDBC data source. The JDBC remoting feature allows hosting the JDBC connection on a server to enable connections from virtually anywhere -- various clients on any platform (Java, .NET, C++, PHP, Python, and so on) and using any standards-based technology (ODBC, JDBC, and so on). JDBC remoting is enabled using the popular MySQL wire protocol server.

SQL Compliance

See SQL Compliance for a syntax reference and code examples outlining the supported SQL.

Data Model

See Data Model for information on the available entities and how to query them.

Connection String Options

The Connection properties describe the various options that can be used to establish a connection.

CData JDBC Driver for Anzo

Getting Started

Connecting to Anzo

Establishing a Connection shows how to authenticate to Anzo and configure any necessary connection properties in a JDBC URL. You can also configure driver capabilities through the available Connection properties, from data modeling to firewall traversal. The Advanced Settings section shows how to set up more advanced configurations and troubleshoot connection errors.

Connecting to JDBC Data Sources

The CData JDBC Driver for Anzo provides full support for integration into Java applications, including Eclipse, NetBeans, IntelliJ IDEA, and many other Integrated Development Environments, as well as J2EE applications running on a Java server such as Tomcat. You can find JSP, console, and swing demos in the installation folder.

Java Version Support

To deploy the driver JAR file, you must have Java Development Kit (JDK) 1.6 or higher installed on your system.

Anzo Version Support

The driver models Anzo entities as a relational database, dynamically discovering the schemas to allow access to all of your Anzo sources.

See Also

CData JDBC Driver for Anzo

Establishing a Connection

Creating a JDBC Data Source

You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for Anzo consists of three basic steps:

  • Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory.
  • Provide the driver class. For example:
    cdata.jdbc.anzo.AnzoDriver
  • Provide the JDBC URL. For example:
    jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;
    
    or
    
    jdbc:cdata:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;

    The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:anzo:" or "jdbc:cdata:anzo:" and can include any of the connection properties in name-value pairs separated with semicolons.

To authenticate to Anzo, you must provide the User and Password properties.

To connect to data, specify Url. This is the Url to your Anzo data.

CData JDBC Driver for Anzo

Building the JDBC URL

Building the JDBC URL

Connection strings provide information about a data source and how to connect to that data source. The driver comes with a connection string builder that makes it easier to create and manage the contents of connection strings.

After downloading and installing the driver, double-click the .jar file in the lib folder. You can also manually run the .jar file, as shown in the following examples.

From Windows:

java -jar 'C:\Program Files\CData\CData JDBC Driver for Anzo 2021\lib\cdata.jdbc.anzo.jar'

From macOS:

java -jar cdata.jdbc.anzo.jar

Running the .jar file opens the Connection Properties dialog box. You can use this dialog box to build and test a connection string. Click Test Connection to test and validate the entered connection properties. Click Copy to Clipboard to copy the connection string for use within the application where the JDBC driver is being used. See the help documentation for more information about the connection string options.

CData JDBC Driver for Anzo

Changelog

General Changes

[7915] - 2021-09-02

Added
  • Added support for the STRING_SPLIT table-valued function in the CROSS APPLY clause.

[7889] - 2021-08-07

Changed
  • Add the KeySeq column to the sys_foreignkeys table.

[7888] - 2021-08-06

Changed
  • Add the new sys_primarykeys system table.

[7874] - 2021-07-23

Changed
  • Updated the Literal Function Names for relative date/datetime functions. Previously relative date/datetime functions resolved to a different value when used in the projection vs te predicate. Ie: SELECT LAST_MONTH() AS lm, Col FROM Table WHERE Col > LAST_MONTH(). Formerly the two LAST_MONTH() methods would resolve to different datetimes. Now they will match.
  • As a replacement for the previous behavior, the relative date/datetime functions in the criteria may have an 'L' appended to them. Ie: WHERE col > L_LAST_MONTH(). This will continue to resolve to the same values that previously were calculated in the criteria. Note that the "L_" prefix will only work in the predicate - it not available for the projection.

[7859] - 2021-07-08

Added
  • Added the TCP Logging Module for the logging information happening on the TCP wire protocol. The transport bytes that are incoming and ongoing will be logged at verbosity=5.

[7785] - 2021-04-23

Added
  • Added support for handling client side formulas during insert / update. For example: UPDATE Table SET Col1 = Concat(Col1, " - ", Col2) WHERE Col2 LIKE 'A%'

[7783] - 2021-04-23

Changed
  • Updated how display sizes are determined for varchar primary key and foreign key columns so they will match the reported length of the column.

[7776] - 2021-04-16

Added
  • Non-conditional updates between two columns is now available to all drivers. For example: UPDATE Table SET Col1=Col2
Changed
  • Reduced the length to 255 for varchar primary key and foreign key columns.
  • Updated implicit and metadata caching to improve performance and support for multiple connections. Old metadata caches are not compatible - you would need to generate new metadata caches if you are currently using CacheMetadata.
  • Updated index naming convention to avoid duplicates
  • Updated and standardized Getting Started connection help.
  • Added the Advanced Features section to the help of all drivers.
  • Categorized connection property listings in the help for all editions.

JDBC Driver Changes

[8090] - 2022-02-24

Changed
  • Correct the return value of method DatabaseMetaData.supportsOuterJoins(), it used to return the wrong value.

[7970] - 2021-10-27

Changed
  • Support for JDK 17

[7925] - 2021-09-12

Removed
  • Removed IS_READONLY, IS_KEY, NUMERIC_PRECISION, DECIMAL_DIGITS from DatabaseMetadata.GetColumns() as they are not part of the JDBC Specification. This information is still available via other metadata calls.

CData JDBC Driver for Anzo

Using JDBC

This section provides a walk-through of writing data access code to Anzo in JDBC.

See Data Model for more information on the available API objects and how to query them with SQL. See SQL Compliance for the SQL syntax.

Connecting from Code

See Establishing a Connection for the prerequisite information you need to deploy the driver and configure the connection to Anzo. Connecting from Code shows how to connect with the DriverManager or AnzoDataSource classes.

Executing SQL

Use the Statement and PreparedStatement classes to execute SQL to Anzo:

  • See Executing Statements to execute Statements and iterate over the returned ResultSets.
  • See Using Prepared Statements to execute parameterized statements. The PreparedStatement class provides a means to efficiently execute queries more than once and to mitigate SQL injection attacks.

Executing Stored Procedures

You can execute stored procedures as parameterized statements (with the CallableStatement class) or SQL statements (with the EXECUTE syntax): see Calling Stored Procedures.

Connection Pooling

Instantiate pooled connections with AnzoDataSource objects: see Connection Pooling to create and configure the pool.

CData JDBC Driver for Anzo

Installed Files

The CData JDBC Driver for Anzo ships the following files, located in the lib subfolder of the installation directory:

  • cdata.jdbc.anzo.jar: Pure Java Type 4/5 JDBC Driver, compiled with JDK 1.6.
  • cdata.jdbc.anzo.remoting.ini: This is the configuration file for JDBC Remoting.

CData JDBC Driver for Anzo

Connecting from Code

This section describes how to connect with the JDBC DriverManager or AnzoDataSource interfaces.

Connecting with the DriverManager

When connecting with the DriverManager class, the CData JDBC Driver for Anzo follows the JDBC convention: First, load the Anzo driver class. Then, make a connection.

Load the Driver

The following step is optional per the JDBC 4.0 specification.
Class.forName("cdata.jdbc.anzo.AnzoDriver");

Establish a Connection

Provide the connection string with the getConnection method of the static DriverManager class. Start the connection string with "jdbc:anzo:". A typical connection string is the following:

Connection conn = DriverManager.getConnection("jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;");
Alternatively, you can prepare the connection options using a Properties object. Pass the Properties object to the DriverManager.
Properties prop = new Properties();
prop.setProperty("Property1","Value1");
prop.setProperty("Property2","Value2");
Connection conn = DriverManager.getConnection("jdbc:anzo:,");
  

Connecting with the AnzoDataSource Class

You can use the AnzoDataSource class to create pooled connections, as shown in the following example. See Connection Pooling for more information.

The following example instantiates a pooled Connection object:

AnzoDataSource ds = new AnzoDataSource("cdata.jdbc.anzo.AnzoDriver", "jdbc:anzo:UseConnectionPooling=true;User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;"); 
Connection conn = ds.getConnection();

CData JDBC Driver for Anzo

Executing Statements

After Connecting from Code, you can execute SQL statements with the Statement class. See Using Prepared Statements to execute parameterized statements.

Select

To execute SQL statements that return data, use the Statement class' generic execute method or the executeQuery method. To return the results of a query, call the getResultSet method of the Statement.

The following example calls the execute method and iterates over the results returned:

Statement stat = conn.createStatement();
boolean ret = stat.execute("SELECT Id, location_displayName FROM [Anzo].[ExpandData].Events");
if (ret) {
  ResultSet rs=stat.getResultSet();
  while(rs.next()) {
    for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
      System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
    }
  }
}

Insert

To execute an insert, use the generic execute method or the executeUpdate method of the Statement class.

To obtain the generated keys for the new records, specify Statement.RETURN_GENERATED_KEYS in the method call. After executing the statement, call Statement.getGeneratedKeys. For example:

Statement stat = conn.createStatement();
int count = stat.executeUpdate("INSERT INTO [Anzo].[ExpandData].Events (Id, location_displayName) VALUES ('Id','location_displayName')",Statement.RETURN_GENERATED_KEYS );
ResultSet rs = stat.getGeneratedKeys();
while(rs.next()) {
  for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
    System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
  }
}

Update

To execute an update, use the generic execute method or the executeUpdate method of the Statement class. You can call the getUpdateCount method to obtain the count of affected rows. Or, call the executeUpdate method; this method returns the row count. For example:

Statement stat = conn.createStatement();
stat.execute("UPDATE [Anzo].[ExpandData].Events SET Id = 'XXX' , location_displayName = 'YYY' WHERE Id = 'Jq74mCczmFXk1tC10GB'");
int count = stat.getUpdateCount();

Delete

To execute a delete, use the generic execute method or the executeUpdate method of the Statement class. You can call the getUpdateCount method to obtain the count of affected rows. Or, call the executeUpdate method; this method returns the row count. For example:

Statement stat = conn.createStatement();
stat.execute("DELETE FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'");
int count = stat.getUpdateCount();

CData JDBC Driver for Anzo

Using Prepared Statements

The PreparedStatement object represents a precompiled SQL statement. A PreparedStatement can be used multiple times and mitigates SQL injection attacks. A PreparedStatement can be a SELECT, INSERT, UPDATE, or DELETE statement.

To execute a prepared statement, you can use the generic execute method of the Statement class. This section describes how to execute a prepared statement.

  1. Instantiate a PreparedStatement object with the prepareStatement method of the Connection class.

    See Connecting from Code to create the connection.

  2. Declare parameters by calling the PreparedStatement's corresponding setter method. Note that the parameter indices start from one.
  3. Call the PreparedStatement's execute method to execute the statement.
  4. Call the PreparedStatement's getResultSet method to pull the results into a ResultSet object.
  5. Call ResultSet.next to iterate over the result set. Use the ResultSetMetaData class to obtain column information about the result set. To instantiate a ResultSetMetaData object, call the ResultSet's getMetaData method.

Select

The following example shows how to execute a SELECT prepared statement:

String query = "SELECT * FROM [Anzo].[ExpandData].Events WHERE Id=? AND location_displayName=?";
PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.setString(1, "XXX");
pstmt.setString(2, "YYY");
boolean ret = pstmt.execute();
if (ret) {
  ResultSet rs=pstmt.getResultSet();
  while(rs.next()) {
    for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
      System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
    }
  }
} 

Insert

To execute an insert, you can use the generic execute method or the executeUpdate method, as shown in the following example.

To obtain the generated keys for new records, specify Statement.RETURN_GENERATED_KEYS in the prepareStatement call. After executing the statement, call the getGeneratedKeys method.

String query = "INSERT INTO [Anzo].[ExpandData].Events (Id, location_displayName) VALUES (?,?)";
PreparedStatement pstmt = conn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS );
pstmt.setString(1, "XXX");
pstmt.setString(2, "YYY");
int count = pstmt.executeUpdate();
ResultSet rs = pstmt.getGeneratedKeys();
while(rs.next()) {
  for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
    System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
  }
}

Update

To execute an update, you can use the generic execute method or the executeUpdate method, as shown in the following example. The executeUpdate method returns the affected rows. Or, call getUpdateCount.

String query = "UPDATE [Anzo].[ExpandData].Events SET location_displayName = ? WHERE Id=?";
PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.setString(1, "XXX");
pstmt.setString(2, "YYY");
int count = pstmt.executeUpdate();
System.out.println("Affected rows: "+count);

Delete

To execute a delete, you can use the generic execute method or the executeUpdate method, as shown in the following example. The executeUpdate method returns the affected rows. Or, call getUpdateCount.

String query = "DELETE FROM [Anzo].[ExpandData].Events WHERE Id = ?";
PreparedStatement pstmt = conn.prepareStatement(query);
pstmt.setString(1, "XXX");
int count = pstmt.executeUpdate();
System.out.println("Affected rows: "+count);

CData JDBC Driver for Anzo

Connection Pooling

The driver implements a standard JDBC connection pool. Set UseConnectionPooling to enable the pool. The following sections show how to configure and use them.

Working with Pooled Connections

Just as you would interact with a non-pooled connection, you use standard JDBC objects to get and close connections. But, in this case, the Connection object retrieved is a handle for the physical connection owned by the connection pool. When the connection is closed, instead of the connection being destroyed, the handle is returned to the pool, where it is available for the next connection request.

You must explicitly close the connection for it to be returned to the pool.

Configuring the Connection Pool

In addition to UseConnectionPooling, set the following connection properties to control the connection pool:

  • PoolMaxSize: Define the maximum number of connections that can be open at any given time.
  • PoolIdleTimeout: Set a limit to how long connections can remain open and idle. If this limit is exceeded, the connection is returned to the pool.
  • PoolWaitTime: Set a limit to how long new connection requests should wait for a connection to become available. If this limit is exceeded, the request throws an error. By default, connection requests wait forever for a connection to become available.

Connection Pooling with AnzoDataSource

To use the default method for pooling connections, instantiate the AnzoDataSource with UseConnectionPooling:

AnzoDataSource anzoDataSource = new AnzoDataSource();
anzoDataSource.setURL("jdbc:anzo:UseConnectionPooling=true;User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;");

JDBC Connection Pooling

If you would like to establish a pooled connection using the the JDBC ConnectionPoolDataSource interface, instantiate the AnzoConnectionPoolDataSource with UseConnectionPooling:

AnzoConnectionPoolDataSource anzoPoolDataSource = new AnzoConnectionPoolDataSource();
anzoPoolDataSource.setURL("jdbc:anzo:UseConnectionPooling=true;User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;");

Closing the Connection Pool

On JRE 1.3 or higher, the connection pool itself automatically closes when the application stops running. You can manually close the connection pool by invoking the close method of the DataSource object.

CData JDBC Driver for Anzo

JNDI

Connection Pooling with JNDI

The Java Naming and Directory Service (JNDI) is an API which allows distributed application to look up services. JNDI can be used to easily set up connection pools.

To set up a connection pool using JNDI, you will need to initialize the JNDI File System Service Provider, as shown in the example code below. To run the example, you need to add the fscontext.jar and providerutil.jar files to your classpath. You can download these files from the Oracle Java Archive: Under the Java SE section, select Java Platform Technologies > Java Naming and Directory Interface.

 
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:///tmp");

Context ctx = new InitialContext(env); 
DataSource ds = null;
Connection conn = null;
The following code registers the AnzoDataSource with the JNDI naming service, gets an instance of the DataSource from the service, and creates pooled connections from that instance.
try {
  AnzoConnectionPoolDataSource anzoDataSource = new AnzoConnectionPoolDataSource();
  anzoDataSource.setURL("jdbc:anzo:UseConnectionPooling=true;User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;");
  ctx.bind("jdbc/anzo", anzoDataSource);
  ds = (DataSource) ctx.lookup("jdbc/anzo");

  conn = ds.getConnection();
  Statement stat = conn.createStatement();
  boolean ret = stat.execute("SELECT 1");
  ResultSet rs=stat.getResultSet(); 
} catch(Exception ex) { } finally {
  if(conn != null) conn.close();
}

CData JDBC Driver for Anzo

Calling Stored Procedures

Use CallableStatement objects to execute parameterized stored procedure calls. Use Statement objects to execute stored procedures as SQL statements with the EXEC syntax.

Using Callable Statement Objects

You can use the generic execute method of the CallableStatement class to execute any stored procedure as a parameterized query.

To return the stored procedure's results, call getResultSet. To return a count of updated rows, call getUpdateCount.

The following example shows how to execute the SendMail stored procedure:

CallableStatement cstmt = conn.prepareCall("SendMail");
cstmt.setString("MessageId", "abc123");
boolean ret = cstmt.execute();   
if (!ret) {
  int count=cstmt.getUpdateCount();
  if (count!=-1) {
    System.out.println("Affected rows: "+count);
  }
}
else {
  ResultSet rs=cstmt.getResultSet();
  while(rs.next()){
    for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
      System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
    }
  }
}

Using Statement Objects

You can use the execute method of the Statement class to execute any stored procedure as an SQL statement.

To return the stored procedure's results, call getResultSet. To return a count of updated rows, call getUpdateCount.

The following example shows how to execute the SendMail stored procedure: (See EXECUTE Statements for more on the syntax.)

Statement stmt = conn.createStatement();
boolean ret = stmt.execute("EXEC SendMail MessageId = 'abc123'");

if (!ret) {
  int count=stmt.getUpdateCount();
  if (count!=-1) {
    System.out.println("Affected rows: "+count);
  }
}
else {
  ResultSet rs=stmt.getResultSet();
  while(rs.next()) {
    for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
      System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
    }
  }
}

CData JDBC Driver for Anzo

Using from Tools

The CData JDBC Driver for Anzo provides the standard JDBC connection process in analytics tools and other applications.

JDBC Integration Quickstarts

The CData JDBC Driver for Anzo provides the standard JDBC connection process in applications ranging from business intelligence tools to IDEs. The following sections show how to create and start querying Anzo JDBC data sources, walking through data access in JDBC from several popular database tools.

Complete List of Anzo Integration Quickstarts

See Anzo integration guides for information on connecting from other applications.

CData JDBC Driver for Anzo

DbVisualizer

This section shows how to establish a connection to data in DbVisualizer, use the table editor to edit and save data, and execute SQL.

Add the JDBC Driver for Anzo

Complete the following steps to add the driver .jar file in a driver definition:

  1. In DbVisualizer, select Tools > Driver Manager and then select Driver > Create Driver.
  2. Enter a name for the driver.
  3. Enter the following in the URL Format box:
    jdbc:anzo:
  4. In the Driver JAR Files section, click the folder icon and browse to the driver .jar file, cdata.jdbc.anzo.jar. By default, this is located in the lib subfolder of the installation directory.
  5. In the Driver Class menu, select the AnzoDriver class, cdata.jdbc.anzo.AnzoDriver.

Create a Database Connection for Anzo

Complete the following steps to select the Anzo driver and build the JDBC URL to create the JDBC data source:

  1. In the main DbVisualizer window, select Tools > Connection Wizard.

  2. Enter an alias for the connection.
  3. Select the driver definition you created.
  4. In the following fields, enter the JDBC URL and provide authentication.

    See Establishing a Connection for a guide.

  5. Database URL: Enter the full JDBC URL. The syntax of the JDBC URL is jdbc:anzo: followed by the connection properties in a semicolon-separated list of name-value pairs.

    A typical connection string is below:

    jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;

  6. Database UserId: Enter the username for authentication to Anzo, if needed.
  7. Database Password: Enter the password for authentication to Anzo, if needed.
Note: After you successfully create a database connection for Anzo you should set the "Database Type" property to "Generic".

Discover Schemas and Query Anzo Data

In the main DbVisualizer window, click Connect on the Connection tab for the newly created connection. You can then browse data and execute SQL in the following ways:

  • To access the available tables, from the Databases tab, expand the nodes for the connection, database, schema, and table or view.
  • To browse through table data and metadata, right-click a table and click Open in New Tab.
  • To execute SQL queries, select SQL Commander > New SQL Commander. Select the Database Connection, Database, and Schema from the available menus.

See Data Model for information on querying specific tables. See SQL Compliance for more information on the SQL syntax.

CData JDBC Driver for Anzo

DBeaver

This section describes how to connect to Anzo following the standard JDBC connection process in DBeaver: Add the driver JAR, provide the driver class name, and provide any Anzo-specific parameters in the JDBC URL.

Add the JDBC Driver for Anzo

Complete the following steps to add the driver .jar file:

  1. Open the DBeaver application and, in the Database menu, select the Driver Manager option. Click New to open the Create New Driver form.
  2. In the Driver Name box, enter a user-friendly name for the driver.
  3. To add the .jar file, click Add File on the Libraries tab. Select the cdata.jdbc.anzo.jar file, located in the lib subfolder of the installation directory.

  4. Click Find Class, and in the list select, "cdata.jdbc.anzo.AnzoDriver".
  5. In the URL Template field, enter jdbc:anzo:.

Create the JDBC Data Source

Complete the following steps to select the Anzo driver and build the JDBC URL to create the JDBC data source:

  1. In the main DBeaver window, click Database > New Connection.
  2. Select the driver definition you created in the dialog that is displayed.
  3. On the next page of the wizard, click the Driver Properties tab.
  4. Enter any connection properties required to connect to Anzo.

    Here is a typical connection string:

    jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;
    See Establishing a Connection for a connection and authentication guide.

  5. Finish creating the connection with the default settings or configure advanced network settings -- proxy, firewall, and SSH.

Discover Schemas and Query Anzo Data

Complete the following steps to query information from the tables exposed by the connection:

  1. Expand the node for the connection to access the database metadata.
  2. Browse the table metadata and edit the table data by right-clicking a Table and then clicking Edit Table.

To execute an SQL query, select SQL Editor > New SQL Editor and select the Anzo connection you created. You can then enter queries using code completion.

CData JDBC Driver for Anzo

SQuirreL SQL

This section describes how to create a JDBC data source for Anzo data and execute queries.

Add the JDBC Driver for Anzo

Complete the following steps to add the driver .jar file:

  1. In the Drivers pane, click the plus icon to open the Add Driver wizard.
  2. In the Name box, enter a user-friendly name for the driver; for example, CData JDBC Driver for Anzo.
  3. In the Example URL box, enter jdbc:anzo:
  4. In the Extra Class Path tab, click Add.
  5. In the file explorer that opens, select the .jar file for the driver, located in the lib subfolder of the installation directory.
  6. Click List Drivers to populate the Class Name menu with the class name for the driver, cdata.jdbc.anzo.AnzoDriver.

Create the JDBC Data Source

Complete the following steps to select the Anzo driver you created and build the JDBC URL to create the JDBC data source:

  1. In the Aliases pane, click the plus icon.
  2. In the Add Alias wizard that opens, provide values for the following fields:

    • Name: Enter a name for the alias; for example, CData Anzo Source.
    • Driver: Select the driver definition you created.
    • URL: Enter jdbc:anzo:
    • User Name: If needed, enter a user name for authentication, which is added to the JDBC URL.
    • Password: If needed, enter a password for authentication, which is added to the JDBC URL.

  3. If you want to define any additional properties, add them to the JDBC URL in a semicolon-separated list.

    The following is a typical connection string:

    jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;
    See Establishing a Connection for a connection and authentication guide.

Or, follow these steps to add the properties in the Driver Properties dialog:
  1. Select the Use Driver Properties check box.
  2. In the Specify column, select the check boxes for the required connection properties and specify the corresponding values.
  3. In the dialog that appears after you click OK, click Connect to test the connection.

Discover Schemas and Query Anzo Data

To connect to the data source, right-click the alias on the Aliases pane and then click Connect. After the metadata has loaded, a new tab for the Anzo data source is displayed. On the Objects subtab, you can discover schema information, such as the available tables and views.

To view table data and metadata, select the table on the Objects tab. Access the table data on the Content tab.

To execute an SQL query, enter the query on the SQL tab and then click Run SQL (the runner icon).

CData JDBC Driver for Anzo

Tableau

This section describes how to connect and start querying data from Tableau.

Add the CData JDBC Driver for Anzo

Note: Before starting Tableau on Windows, make sure that you have placed the .jar file in the C:\Program Files\Tableau\Drivers folder. Before starting Tableau on macOS, make sure that you have placed the .jar file in the ~/Library/Tableau/Drivers folder.

To add the driver .jar file:

  1. Start Tableau.
  2. Under To a Server, select More.
  3. Select Other Databases (JDBC).
  4. Enter the JDBC connection string in the URL field. See Building the JDBC URL for Anzo below for more information.
  5. Select Sign in.

Building the JDBC URL for Anzo

Connection strings provide information about a data source and how to connect to that data source. The driver comes with a connection string builder that makes it easier to create and manage the contents of connection strings.

After downloading and installing the driver, double-click the .jar file in the lib folder. You can also manually run the .jar file, as shown in the following examples.

From Windows:

java -jar 'C:\Program Files\CData\CData JDBC Driver for Anzo 2021\lib\cdata.jdbc.anzo.jar'

From macOS:

java -jar cdata.jdbc.anzo.jar

Running the .jar file opens the Connection Properties dialog box. You can use this dialog box to build and test a connection string. Click Test Connection to test and validate the entered connection properties. Click Copy to Clipboard to copy the connection string for use within the application where the JDBC driver is being used. See the help documentation for more information about the connection string options.

Discover Schemas and Query Data

To query data:

  1. Select CData from the Database pull-down menu.
  2. Select Odata from the Schema pull-down menu.
  3. Drag the table onto the join area. You can include multiple tables.
  4. Select Update Now or Automatically Update. Update Now lets you preview the first 10,000 rows of the data source (or enter the number of rows you want to see in the Rows text box). Automatically Update automatically reflects the changes in the preview area.
  5. In the Connection menu, select the Live option, so that you skip loading a copy of the data into Tableau and instead work on real-time data.
  6. Click the tab for your worksheet. Columns are listed as Dimensions and Measures, depending on the data type.

CData JDBC Driver for Anzo

Schema Discovery

The driver supports schema discovery using JDBC classes or using SQL queries to the available system tables. The JDBC classes enable access to schema information, connection property information, and information on the columns returned.

Through SQL queries to the available System Tables, you can access schema and connection property information as well as information on data source functionality and statistics on update operations.

Using JDBC Interfaces

You can use JDBC interfaces to access schema information, connection property metadata, and result set metadata. The driver implements the standard interfaces as defined in the JDBC 4.0 specification.

Retrieving Schema Information

The DatabaseMetaData class provides information on the following:

Retrieving Connection Property Information

The Driver class, returned by DriverManager, provides information about Connection Properties.

Retrieving Result Set Column Information

The ResultSetMetaData class provides information about the columns returned in Result Sets.

Using SQL

You can query the System Tables to access any metadata surfaced through the driver.

CData JDBC Driver for Anzo

Tables

You can use the getTables method of the DatabaseMetaData interface to retrieve a list of tables:

String connectionString = "jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";

Connection conn = DriverManager.getConnection(connectionString);
DatabaseMetaData table_meta = conn.getMetaData();
ResultSet rs=table_meta.getTables(null, null, "%", null);  
while(rs.next()){
  System.out.println(rs.getString("TABLE_NAME"));
}
The getTables method returns the following columns:

Column NameData TypeDescription
TABLE_CATStringThe table catalog.
TABLE_SCHEMStringThe table schema.
TABLE_NAMEStringThe table name.
TABLE_TYPEStringThe table type.
REMARKSStringThe table description.

CData JDBC Driver for Anzo

Columns

You can use the getColumns method of the DatabaseMetaData interface to retrieve column information. You can restrict the results by the table name. The code example below retrieves the column names for the [Anzo].[ExpandData].Events table:

String connectionString = "jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";

Connection conn = DriverManager.getConnection(connectionString);
DatabaseMetaData table_meta = conn.getMetaData();
ResultSet rs = table_meta.getColumns("Anzo","ExpandData","Events", null);
while(rs.next()){
  System.out.println(rs.getString("COLUMN_NAME")); 
}
The getColumns method returns the following columns:

Column NameData TypeDescription
TABLE_CATStringThe database name.
TABLE_SCHEMStringThe table schema.
TABLE_NAMEStringThe table name.
COLUMN_NAMEStringThe column name.
DATA_TYPEintThe data type identified by the value of a constant defined in java.sql.Types.
TYPE_NAMEStringThe data type name used by the driver.
COLUMN_SIZEintThe length in characters of the column or the numeric precision.
BUFFER_LENGTHintThe buffer length.
DECIMAL_DIGITSintThe column scale or number of digits to the right of the decimal point.
NUM_PREC_RADIXintThe radix, or base.
NULLABLEintWhether the column can contain null as defined by the following JDBC DatabaseMetaData constants: columnNoNulls (0) or columnNullable (1).
REMARKSStringThe column description.
COLUMN_DEFStringThe default value for the column.
SQL_DATA_TYPEintReserved by the specification.
SQL_DATETIME_SUBintReserved by the specification.
CHAR_OCTET_LENGTHintThe maximum length of binary and character-based columns.
ORDINAL_POSITIONintThe column index, starting at 1.
IS_NULLABLEStringWhether a null value is allowed: YES or NO.
SCOPE_CATALOGStringThe table catalog that is the scope of a reference attribute.
SCOPE_SCHEMAStringThe table schema that is the scope of a reference attribute.
SCOPE_TABLEStringThe table name that is the scope of a reference attribute.
SOURCE_DATA_TYPEintThe source type of a distinct type. Or, a user-generated Ref type. If DATA_TYPE is not DISTINCT, this value is null. If a user-generated Ref, this value is null.
IS_AUTOINCREMENTStringWhether the column value is assigned by Anzo in fixed increments.
IS_GENERATEDCOLUMNStringWhether the column is generated: YES or NO.

CData JDBC Driver for Anzo

Procedures

You can use the DatabaseMetaData interface to retrieve stored procedure information. The getProcedures method returns descriptions of the available stored procedures.

The following code retrieves the names of the available stored procedures:

String connectionString = "jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";

Connection conn = DriverManager.getConnection(connectionString);
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs = meta.getProcedures(null, null, "%");
while(rs.next()){
  System.out.println(rs.getString("PROCEDURE_NAME"));
}
The getProcedures method returns the following columns:

Column NameData TypeDescription
PROCEDURE_CATStringThe catalog the procedure belongs to.
PROCEDURE_SCHEMStringThe schema the procedure belongs to.
PROCEDURE_NAMEStringThe stored procedure name.
REMARKSStringThe description of the stored procedure.
PROCEDURE_TYPEshortReturns 2 if the procedure returns a result. Returns 1 if the procedure does not return a result. Returns 0 if unknown.
SPECIFIC_NAMEStringThe name that uniquely identifies the stored procedure within its schema.

CData JDBC Driver for Anzo

Procedure Parameters

You can use the DatabaseMetaData interface to retrieve stored procedure information. The getProcedureColumns method returns descriptions of stored procedure parameters. You can restrict the results by the stored procedure name.

The following code example outputs information about the parameters of the SendMail stored procedure:

String connectionString = "jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";

Connection conn = DriverManager.getConnection(connectionString);
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs=meta.getProcedureColumns(null, null, "SendMail", null);  
while(rs.next()) {   
  for(int i=1;i<=rs.getMetaData().getColumnCount();i++)  {
    System.out.println(rs.getMetaData().getColumnName(i) +"="+rs.getString(i));
  }
}
The getProcedureColumns method returns the following columns:

Column NameData TypeDescription
PROCEDURE_CATStringThe catalog that the procedure belongs to.
PROCEDURE_SCHEMStringThe schema that the procedure belongs to.
PROCEDURE_NAMEStringThe name of the stored procedure.
COLUMN_NAMEStringThe name of the procedure column.
COLUMN_TYPEStringThe type of procedure column as defined by the following DatabaseMetaData constants: procedureColumnIn (1), procedureColumnInOut (2), procedureColumnResult (3), procedureColumnOut (4), and procedureColumnReturn (5).
DATA_TYPEintThe data type name as defined in java.sql.Types.
TYPE_NAMEStringThe driver-defined data type name.
PRECISIONintThe number of digits allowed for numeric data.
LENGTHintThe number of characters allowed for character data. The number of digits allowed for numeric data.
SCALEshortThe number of digits to the right of the decimal point in numeric data.
RADIXshortThe radix, or base.
NULLABLEshortWhether the parameter can contain null as defined by the following DatabaseMetaData constants: parameterNoNulls (0), parameterNullable (1), and parameterNullableUnknown (2).
REMARKSStringThe description of the parameter.
COLUMN_DEFStringThe default value for the parameter.
SQL_DATA_TYPEintReserved in the specification.
SQL_DATETIME_SUBintReserved in the specification.
CHAR_OCTET_LENGTHintThe maximum length of binary-based and character-based columns. Null for other data types.
ORDINAL_POSITIONintThe index of the output parameter.
IS_NULLABLEStringWhether the column can include null: YES or NO.
SPECIFIC_NAMEStringThe name that uniquely identifies the stored procedure within its schema.

CData JDBC Driver for Anzo

Primary Keys

You can use the getPrimaryKeys method to return information about the primary keys for Anzo tables. You can restrict the results by the table name.

The following code example outputs the column or columns composing the primary key for the [Anzo].[ExpandData].Events table:

String connectionString = "jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";

Connection conn = DriverManager.getConnection(connectionString);
ResultSet rs = conn.getMetaData().getPrimaryKeys("Anzo","ExpandData","Events");
while(rs.next()){
  System.out.println(rs.getString("COLUMN_NAME"));
}

The getPrimaryKeys method returns the following columns:

Column NameData TypeDescription
TABLE_CATStringThe table catalog
TABLE_SCHEMStringThe table schema.
TABLE_NAMEStringThe table name.
COLUMN_NAMEStringThe column name.
KEY_SEQshortThe sequence number, or column index starting from 1, within the foreign key.
PK_NAMEStringThe primary key name.

CData JDBC Driver for Anzo

Connection Properties

The available connection properties can be retrieved with the getPropertyInfo method of the Driver class. This method returns an array with elements of type DriverPropertyInfo.

String connectionString = "jdbc:anzo:";

Driver driver = DriverManager.getDriver(connectionString);
Properties info = new Properties();
DriverPropertyInfo[] attr = driver.getPropertyInfo(connectionString,info);
for(int i=0;i<attr.length;i++){
  System.out.println(attr[i].name);
  System.out.println(attr[i].description);
  System.out.println(attr[i].required);
  System.out.println(attr[i].value);
  String[] c = attr[i].choices;
  if(c != null) {
    for(String s: c)
      System.out.println(s);
  }
}

The DriverPropertyInfo class has the following properties:

Property NameData TypeDescription
NameStringThe name of the connection property.
DescriptionStringThe description for the connection property.
RequiredbooleanWhether the connection property must be set to connect to Anzo.
ChoicesString[]An array of the allowed values for the connection property.
ValueStringThe current value of the connection property or the default value if one is not set by the user.

CData JDBC Driver for Anzo

Result Sets

You can use ResultSetMetaData to retrieve metadata about the results of a query.

The query can contain any of the following:

  • Joins
  • Aggregates
  • Aliases
  • Fully qualified names
  • Generated columns

You can instantiate a ResultSetMetaData object by invoking the getMetaData method of the Statement class. A ResultSetMetaData instance is populated with data after the statement has been executed. The following query prints out the columns in the result of the query:

String connectionString = "jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";

Connection conn = DriverManager.getConnection(connectionString);
PreparedStatement pstmt = conn.prepareStatement("SELECT Id, location_displayName AS My_location_displayName, GETDATE() FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'");
pstmt.executeQuery();
ResultSetMetaData rs = pstmt.getMetaData();
for(int i=1;i<=rs.getColumnCount();i++) {
  System.out.println(rs.getColumnName(i));
}

CData JDBC Driver for Anzo

Advanced Features

This section details a selection of advanced features of the Anzo driver.

User Defined Views

The driver allows you to define virtual tables, called user defined views, whose contents are decided by a pre-configured query. These views are useful when you cannot directly control queries being issued to the drivers. See User Defined Views for an overview of creating and configuring custom views.

SSL Configuration

Use SSL Configuration to adjust how driver handles TLS/SSL certificate negotiations. You can choose from various certificate formats; see the SSLServerCert property under "Connection String Options" for more information.

Firewall and Proxy

Configure the driver for compliance with Firewall and Proxy, including Windows proxies and HTTP proxies. You can also set up tunnel connections.

JDBC Remoting

Configure JDBC Remoting to connect to the driver from remote machines. You can choose between remoting via CLI and using a configuration file.

Caching Data

Caching Data enables faster access to data and reduces the number of API calls, improving performance. The connector supports a simple caching model where multiple connections can also share the cache over time. When configuring the cache connection, you can specify automatic or explicit data caching.

Logging

See Logging for an overview of configuration settings that can be used to refine CData logging. For basic logging, you only need to set two connection properties, but there are numerous features that support more refined logging, where you can select subsets of information to be logged using the LogModules connection property.

CData JDBC Driver for Anzo

User Defined Views

The CData JDBC Driver for Anzo allows you to define a virtual table whose contents are decided by a pre-configured query. These are called User Defined Views, which are useful in situations where you cannot directly control the query being issued to the driver, e.g. when using the driver from a tool. The User Defined Views can be used to define predicates that are always applied. If you specify additional predicates in the query to the view, they are combined with the query already defined as part of the view.

There are two ways to create user defined views:

  • Create a JSON-formatted configuration file defining the views you want.
  • DDL statements.

Defining Views Using a Configuration File

User Defined Views are defined in a JSON-formatted configuration file called UserDefinedViews.json. The driver automatically detects the views specified in this file.

You can also have multiple view definitions and control them using the UserDefinedViews connection property. When you use this property, only the specified views are seen by the driver.

This User Defined View configuration file is formatted as follows:

  • Each root element defines the name of a view.
  • Each root element contains a child element, called query, which contains the custom SQL query for the view.

For example:

{
	"MyView": {
		"query": "SELECT * FROM [Anzo].[ExpandData].Events WHERE MyColumn = 'value'"
	},
	"MyView2": {
		"query": "SELECT * FROM MyTable WHERE Id IN (1,2,3)"
	}
}
Use the UserDefinedViews connectio property to specify the location of your JSON configuration file. For example:
"UserDefinedViews", "C:\\Users\\yourusername\\Desktop\\tmp\\UserDefinedViews.json"

Defining Views Using DDL Statements

The driver is also capable of creating and altering the schema via DDL Statements such as CREATE LOCAL VIEW, ALTER LOCAL VIEW, and DROP LOCAL VIEW.

Create a View

To create a new view using DDL statements, provide the view name and query as follows:

CREATE LOCAL VIEW [MyViewName] AS SELECT * FROM Customers LIMIT 20;

If no JSON file exists, the above code creates one. The view is then created in the JSON configuration file and is now discoverable. The JSON file location is specified by the UserDefinedViews connection property.

Alter a View

To alter an existing view, provide the name of an existing view alongside the new query you would like to use instead:

ALTER LOCAL VIEW [MyViewName] AS SELECT * FROM Customers WHERE TimeModified > '3/1/2020';

The view is then updated in the JSON configuration file.

Drop a View

To drop an existing view, provide the name of an existing schema alongside the new query you would like to use instead.

DROP LOCAL VIEW [MyViewName]

THis removes the view from the JSON configuration file. It can no longer be queried.

Schema for User Defined Views

User Defined Views are exposed in the UserViews schema by default. This is done to avoid the view's name clashing with an actual entity in the data model. You can change the name of the schema used for UserViews by setting the UserViewsSchemaName property.

Working with User Defined Views

For example, a SQL statement with a User Defined View called UserViews.RCustomers only lists customers in Raleigh:
SELECT * FROM Customers WHERE City = 'Raleigh';
An example of a query to the driver:
SELECT * FROM UserViews.RCustomers WHERE Status = 'Active';
Resulting in the effective query to the source:
SELECT * FROM Customers WHERE City = 'Raleigh' AND Status = 'Active';
That is a very simple example of a query to a User Defined View that is effectively a combination of the view query and the view definition. It is possible to compose these queries in much more complex patterns. All SQL operations are allowed in both queries and are combined when appropriate.

CData JDBC Driver for Anzo

SSL Configuration

Customizing the SSL Configuration

By default, the driver attempts to negotiate SSL/TLS by checking the server's certificate against the system's trusted certificate store.

To specify another certificate, see the SSLServerCert property for the available formats to do so.

CData JDBC Driver for Anzo

Firewall and Proxy

Connecting Through a Firewall or Proxy

HTTP Proxies

To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false.

In addition, to authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.

Other Proxies

Set the following properties:

  • To use a proxy-based firewall, set FirewallType, FirewallServer, and FirewallPort.
  • To tunnel the connection, set FirewallType to TUNNEL.
  • To authenticate, specify FirewallUser and FirewallPassword.
  • To authenticate to a SOCKS proxy, additionally set FirewallType to SOCKS5.

CData JDBC Driver for Anzo

JDBC Remoting

The JDBC remoting feature allows you to connect to the JDBC driver from remote machines. The remoting feature is a daemon process that listens for database queries and responds to them. The driver supports the MySQL protocol for remoting.

JDBC remoting will allow any MySQL or SQL Server client (ODBC drivers, programming languages like PHP, Perl, Python, tools like MySQL workbench, and many other applications) to easily connect to Anzo.

Configuring the Driver for Remoting

Remoting can be configured through either a Command Line Interface or an INI-formatted configuration file.

Remoting via CLI

The MySQL daemon can be started directly from the command line. This can be accomplish by invoking the JAR and specifying the necessary CLI Options.

Remoting with a Configuration File

If you prefer not to provide every configuration property directly in the command line, a Configuration File can be defined, which will explicitly list all properties. Once defined, the daemon can be started with a single reference to this file in the CLI.

CData JDBC Driver for Anzo

CLI Options

You can start the MySQL daemon from the command line, as shown below:

java -jar cdata.jdbc.anzo.jar [ options ]
The following command-line options are available:

OptionDescription
-h, --helpDisplay help for available options and exit.
-f, --config-fileThe configuration file for the daemon.
-u, --userThe user allowed to connect. Use a configuration file to configure multiple users. If a user is specified on the command line, then only that user is given access.
-p, --passwordThe password for the user specified with the user option. If both user and password are set on the command line, the users section in the config file is ignored.
-d, --databaseThe database that clients will use to connect. If multiple databases are specified in the config file, connections are allowed to only the database specified on the command line.
-c, --connectionThe connection string used to connect to the data source being surfaced. If no connection string is specified on the command line, the connection string is read from the config file.
-P, --portThe port number to use to listen for TCP/IP connections. The default port is 3306.
-m, --max-connectionsThe maximum number of allowed TCP/IP connections. The default value is 25 connections.
--session-timeoutThe session timeout time in seconds. The default timeout is 20 seconds.
-t, --protocolThe protocol used for remoting. The default value is MySQL.
-g, --logfileThe full path of the log file.
-F, --logrotationschemeThe interval at which to truncate the logs. The options are 1 (daily in the format [MyFileName]_2016_3_21.txt), 2 (weekly in the format [MyFileName]_Week_5.txt, where 5 is the fifth week in the year), and 3 (monthly in the format [MyFileName]_2016_3_21.txt).
-v, --verbosityThe verbosity of the log. 1 is informational. Levels up to 5 add the following subsequent details: (2) HTTP headers, (3) the HTTP body, (4) transport-level communication including SSL, and (5) interface commands and other data source communication.
--testThe database to test the connection with. If this property is not specified, the default database is used.
--ssl-certThe path to the SSL certificate.
--ssl-subjectThe subject of the SSL certificate.
--ssl-passwordThe password of the SSL certificate.
-n, --nodeidDisplays the NodeId of this machine.
-l, --licenseInstalls the license on this machine. This option will prompt you for the type of license and other details.

Options specified on the command line take precedence over options specified in the config file. You can pass in command-line options to specify a restricted subset of the options allowed in the Configuration File.

CData JDBC Driver for Anzo

Configuration File

You can save configuration settings for MySQL remoting in a config file. The file must be structured in the INI file format. Specify this file with the -f command-line option. The config file can have the following sections:

[mysqld]

In the mysqld section, use the following properties to configure the MySQL daemon:

NameDescription
portThe port number to use to listen for TCP/IP connections. The default port is 3306.
max-connectionsThe maximum number of allowed TCP/IP connections. 25 is the default.
session-timeoutThe session timeout time in seconds. The default timeout is 20 seconds.
logfileThe full path of the log file.
verbosityThe verbosity of the log. 1 is informational. Levels up to 5 add the following subsequent details: (2) HTTP headers, (3) the HTTP body, (4) transport-level communication including SSL, and (5) interface commands and other data source communication.
logrotationschemeThe interval at which to truncate the logs. The options are 1 (daily in the format [MyFileName]_2016_3_21.txt), 2 (weekly in the format [MyFileName]_Week_5.txt, where 5 is the fifth week in the year), and 3 (monthly in the format [MyFileName]_2016_3_21.txt).

The default is 2.

ssl-certThe path to the SSL certificate.
ssl-subjectThe subject of the SSL certificate.
ssl-passwordThe password of the SSL certificate.

[databases]

In the databases section, define keys that map the MySQL database or the SQL Server catalog to Anzo connection strings. Clients connect to the MySQL database or the SQL Server catalog defined here. To connect to Anzo, the driver uses the connection string that corresponds to this key.

[databases]
Anzo = "User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;"

[users]

In the users section, define the usernames and passwords of the users of the server. If the acl section is not defined, all users have access to all databases.

[mysql_vars]

In the mysql_vars section, define system variables for the MySQL server. The standard variables are supported. Below are several examples:

NameDescription
version_commentThis value is hard-coded as CData JDBC Driver for Anzo (MySQL Remoting).
character_set_clientThe character_set used in statements sent by the client.

[acl]

In the acl section, allow users to access Anzo databases. Databases must be defined in the databases section. Users must be defined in the users section. Use commas to separate users authorized to access the specified database.

Example Config File

Below is an example config file. The example includes all properties required to configure the server. It also shows how to configure access control for several users and Anzo instances.

[mysqld]
port = 3306
max-connections = 25
session-timeout = 20
logfile = AnzoRemotingLog.txt
verbosity = 2
ssl-cert = "CData.JDBC.Anzo.Remoting.pfx"
ssl-subject = <subject>
ssl-password = <password>

[databases]
Anzo = "User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;"
Anzo_ReadOnly = "User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;ReadOnly=True"

[users]
root = <password>
test = <password>

[mysql_vars]
version_comment =  "CData JDBC Driver for Anzo (MySQL Remoting)"

[acl]
Anzo = root
Anzo_ReadOnly = root, test

You can further restrict the allowed options by passing in options on the command line. See CLI Options for more information.

CData JDBC Driver for Anzo

Caching Data

Caching Data

Caching data provides several benefits, including faster access to data and reducing the number of API calls, which improve performance. The connector supports a simple caching model where multiple connections can also share the cache over time. You can enable and configure caching features by setting the necessary connection properties.

Contents

The sections in this chapter detail the driver's caching functionality and link to the corresponding connection properties, as well as SQL statements.

Configuring the Cache Connection

Configuring the Cache Connection describes the properties that you can set when configuring the cache database.

Caching Metadata

Caching Metadata describes the CacheMetadata property. This property determines whether or not to cache the table metadata to a file store.

Automatically Caching Data

Automatically Caching Data describes how the driver automatically refreshes the cache when the AutoCache property is set.

Explicitly Caching Data

Explicitly Caching Data describes how you can decide what data is stored in the cache and when it is updated.

Data Type Mapping

Data Type Mapping shows the mappings between the data types configured in the schema and the data types in the database.

CData JDBC Driver for Anzo

Configuring the Cache Connection

Configuring the Caching Database

This section describes the properties for caching data to the persistent store of your choice.

CacheLocation

The CacheLocation property species the path to a file-system-based database. When caching is enabled, a file-system-based database is used by default. If CacheLocation is not specified, this database is stored at the path in Location. If neither of these connection properties are specified, the driver uses a platform-dependent default location.

CacheConnection

The CacheConnection property specifies a database driver and the connection string to the caching database.

CacheDriver

The CacheDriver property specifies a database driver and the connection string to the caching database.

CData JDBC Driver for Anzo

Caching Metadata

This section describes how to enable caching metadata and how to update the metadata cache.

Before being able to query data, the connector requires relevant metadata to be retrieved. By default, metadata is cached in memory and shared across connections. But if you want to persist across processes, or if metadata requests are expensive, the solution is to cache the metadata to disk.

Enable Caching Metadata

To enable caching of metadata, set CacheMetadata = true and see Configuring the Cache Connection for instructions on how to configure your connection string. The driver caches the metadata the first time it is needed and uses the metadata cache for subsequent requests.

Update the Metadata Cache

Because metadata is cached, changes to metadata on the live source, for example, adding or removing a column or attribute, are not automatically reflected in the metadata cache. To get updates to the live metadata, you need to delete or drop the cached data.

Cache Metadata from Code

The following code can be used to build the metadata cache. This is especially useful when using the Object-Relational Mapping Framework (for example, Hibernate).

Connection conn = DriverManager.getConnection("jdbc:anzo:Cache Location=C:\\cdata.anzo.db;AutoCache=True;User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;");
DatabaseMetaData table_meta = conn.getMetaData();

ResultSet rs=table_meta.getTables(null, null, "%", null); 

while (rs.next()) {
  String tableName = rs.getString("TABLE_NAME");
  System.out.println("Cached metadata for table: "+tableName);
  ResultSet cols = table_meta.getColumns(null, null, tableName, null);
  while(rs.next()){
  }
}
System.out.println();
System.out.println("All tables cached.");
conn.close();

CData JDBC Driver for Anzo

Automatically Caching Data

Automatically caching data is useful when you do not want to rebuild the cache for each query. When you query data for the first time, the driver automatically initializes and builds a cache in the background. When AutoCache = true, the driver uses the cache for subsequent query executions, resulting in faster response times.

Configuring Automatic Caching

Caching the Events Table

The following example caches the Events table in the file specified by the CacheLocation property of the connection string.

String connectionString = "jdbc:anzo:Cache Location=C:\\cache.db;" +
                          "AutoCache=true;" +
                          "User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;";
Connection connection = DriverManager.getConnection(connectionString);
Statement stat = connection.createStatement();
boolean ret = stat.execute("SELECT Id, location_displayName FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'");
ResultSet rs=stat.getResultSet();
while(rs.next()){
  System.out.println("Read and cached the row with Id "+rs.getString("Id"));
}
connection.close();

Common Use Case

A common use for automatically caching data is to improve driver performance when making repeated requests to a live data source, such as building a report or creating a visualization. With auto caching enabled, repeated requests to the same data may be executed in a short period of time, but within an allowable tolerance (CacheTolerance) of what is considered "live" data.

CData JDBC Driver for Anzo

Explicitly Caching Data

With explicit caching (AutoCache = false), you decide exactly what data is cached and when to query the cache instead of the live data. Explicit caching gives you full control over the cache contents by using CACHE Statements. This section describes some strategies to use the caching features offered by the driver.

Creating the Cache

To load data in the cache, issue the following statement.

CACHE SELECT * FROM tableName WHERE ...

Once the statement is issued, any matching data in tableName is loaded into the corresponding table.

Updating the Cache

This section describes two ways to update the cache.

Updating with the SELECT Statement

The following example shows a statement that can update modified rows and add missing rows in the cached table. However, this statement does not delete extra rows that are already in the cache. This statement only merges the new rows or updates the existing rows.

String cmd = "CACHE SELECT * FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'", connection";
stat.execute(cmd);
connection.close();

Updating with the TRUNCATE Statement

The following example shows a statement that can update modified rows and add missing rows in the cached table. This statement can also delete rows in the cache table that are not present in the live data source.

String cmd = "CACHE WITH TRUNCATE SELECT * FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'";
stat.execute(cmd);
connection.close();

Query the Data in Online or Offline Mode

This section describes how to query the data in online or offline mode.

Online: Select Cached Tables

You can use the tableName#CACHE syntax to explicitly execute queries to the cache while still online, as shown in the following example.

SELECT * FROM [Anzo].[ExpandData].Events#CACHE

Offline: Select Cached Tables

With Offline = true, SELECT statements always execute against the local cache database, regardless of whether you explicitly specify the cached table or not. Modification of the cache is disabled in Offline mode to prevent accidentally updating only the cached data. Executing a DELETE/UPDATE/INSERT statement while in Offline mode results in an exception.

The following example selects from the local cache but not the live data source because Offline = true.

Connection connection = DriverManager.getConnection("jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;Offline=true;Cache Location=C:\\cache.db;");
Statement stat = connection.createStatement();
String query = "SELECT * FROM [Anzo].[ExpandData].Events WHERE Id='Jq74mCczmFXk1tC10GB' ORDER BY location_displayName ASC";
stat.execute(query);
connection.close();

Delete Data from the Cache

You can delete data from the cache by building a direct connection to the database. Note that the driver does not support manually deleting data from the cache.

Common Use Case

A common use for caching is to have an application always query the cached data and only update the cache at set intervals, such as once every day or every two hours. There are two ways in which this can be implemented:

  • AutoCache = false and Offline = false. All queries issued by the application explicitly reference the tableName#CACHE table. When the cache needs to be updated, the application executes a tableName#CACHE ... statement to bring the cached data up to date.
  • Offline = true. Caching is transparent to the application. All queries are executed against the table as normal, so most application code does not need to be aware that caching is done. To update the cached data, simply create a separate connection with Offline = false and execute a tableName#CACHE ... statement.

CData JDBC Driver for Anzo

Data Type Mapping

The driver maps types from the data source to the corresponding data type available in the chosen cache database. The following table shows the mappings between the data types configured in the schema and the data types in the database. Some schema types have synonyms which are all listed in the Schema column.

Data Type Mapping

Note: String columns can map to different data types depending on their length.

Schema .NET JDBC SQL Server Derby MySQL Oracle SQLite Access
int, integer, int32 Int32 int int INTEGER INT NUMBER integer LONG
smallint, short, int16 Int16 short smallint SMALLINT SMALLINT NUMBER integer SHORT
double, float, real Double double float DOUBLE DOUBLE NUMBER double DOUBLE
date DateTime java.sql.Date date DATE DATE DATE date DATETIME
datetime, timestamp DateTime java.sql.Date datetime TIMESTAMP DATETIME TIMESTAMP datetime DATETIME
time, timespan TimeSpan java.sql.Time time TIME TIME TIMESTAMP datetime DATETIME
string, varchar String java.lang.String If length > 4000: nvarchar(max), Otherwise: nvarchar(length)If length > 32672: LONG VARCHAR, Otherwise VARCHAR(length)If length > 255: LONGTEXT, Otherwise: VARCHAR(length)If length > 4000: CLOB, Otherwise: VARCHAR2(length)nvarchar(length)If length > 255: LONGTEXT, Otherwise: VARCHAR(length)
long, int64, bigint Int64 long bigint BIGINT BIGINT NUMBER bigint LONG
boolean, bool Boolean boolean tinyint SMALLINT BIT NUMBER tinyint BIT
decimal, numeric Decimal java.math.BigDecimal decimal DECIMAL DECIMAL DECIMAL decimal CURRENCY
uuid Guid java.util.UUID nvarchar(length) VARCHAR(length)VARCHAR(length) VARCHAR2(length)nvarchar(length) VARCHAR(length)
binary, varbinary, longvarbinary byte[] byte[] binary(1000) or varbinary(max) after SQL Server 2000, image otherwise BLOB LONGBLOB BLOB BLOB LONGBINARY

CData JDBC Driver for Anzo

Logging

Capturing driver logging can be very helpful when diagnosing error messages or other unexpected behavior.

Basic Logging

You will simply need to set two connection properties to begin capturing driver logging.

  • Logfile: A filepath which designates the name and location of the log file.
  • Verbosity: This is a numerical value (1-5) that determines the amount of detail in the log. See the page in the Connection Properties section for a breakdown of the five levels.
  • MaxLogFileSize: When the limit is hit, a new log is created in the same folder with the date and time appended to the end. The default limit is 100 MB. Values lower than 100 kB will use 100 kB as the value instead.
  • MaxLogFileCount: A string specifying the maximum file count of log files. When the limit is hit, a new log is created in the same folder with the date and time appended to the end and the oldest log file will be deleted. Minimum supported value is 2. A value of 0 or a negative value indicates no limit on the count.

Once this property is set, the driver will populate the log file as it carries out various tasks, such as when authentication is performed or queries are executed. If the specified file doesn't already exist, it will be created.

Log Verbosity

The verbosity level determines the amount of detail that the driver reports to the Logfile. Verbosity levels from 1 to 5 are supported. These are described in the following list:

1Setting Verbosity to 1 will log the query, the number of rows returned by it, the start of execution and the time taken, and any errors.
2Setting Verbosity to 2 will log everything included in Verbosity 1, cache queries, and additional information about the request.
3Setting Verbosity to 3 will additionally log HTTP headers, as well as the body of the request and the response.
4Setting Verbosity to 4 will additionally log transport-level communication with the data source. This includes SSL negotiation.
5Setting Verbosity to 5 will additionally log communication with the data source and additional details that may be helpful in troubleshooting problems. This includes interface commands.

The Verbosity should not be set to greater than 1 for normal operation. Substantial amounts of data can be logged at higher verbosities, which can delay execution times.

To refine the logged content further by showing/hiding specific categories of information, see LogModules.

Java Logging

When Java logging is enabled in Logfile, the Verbosity will instead map to the following logging levels.

  • 0: Level.WARNING
  • 1: Level.INFO
  • 2: Level.CONFIG
  • 3: Level.FINE
  • 4: Level.FINER
  • 5: Level.FINEST

Advanced Logging

You may want to refine the exact information that is recorded to the log file. This can be accomplished using the LogModules property.

This property allows you to filter the logging using a semicolon-separated list of logging modules.

All modules are four characters long. Please note that modules containing three letters have a required trailing blank space. The available modules are:

  • EXEC: Query Execution. Includes execution messages for original SQL queries, parsed SQL queries, and normalized SQL queries. Query and page success/failure messages appear here as well.
  • INFO: General Information. Includes the connection string, driver version (build number), and initial connection messages.
  • HTTP: HTTP Protocol messages. Includes HTTP requests/responses (including POST messages), as well as Kerberos related messages.
  • SSL : SSL certificate messages.
  • OAUT: OAuth related failure/success messages.
  • SQL : Includes SQL transactions, SQL bulk transfer messages, and SQL result set messages.
  • META: Metadata cache and schema messages.
  • TCP : Incoming and Ongoing raw bytes on TCP transport layer messages.
An example value for this property would be.
LogModules=INFO;EXEC;SSL ;SQL ;META;

Note that these modules refine the information as it is pulled after taking the Verbosity into account.

CData JDBC Driver for Anzo

SQL Compliance

The CData JDBC Driver for Anzo supports several operations on data, including querying, deleting, modifying, and inserting.

SELECT Statements

See SELECT Statements for a syntax reference and examples.

See Data Model for information on the capabilities of the Anzo API.

INSERT Statements

See INSERT Statements for a syntax reference and examples, as well as retrieving the new records' Ids.

UPDATE Statements

The primary key Id is required to update a record. See UPDATE Statements for a syntax reference and examples.

DELETE Statements

The primary key Id is required to delete a record. See DELETE Statements for a syntax reference and examples.

CACHE Statements

CACHE statements allow granular control over the driver's caching functionality. For a syntax reference and examples, see CACHE Statements.

For more information on the caching feature, see Caching Data.

EXECUTE Statements

Use EXECUTE or EXEC statements to execute stored procedures. See EXECUTE Statements for a syntax reference and examples.

Names and Quoting

  • Table and column names are considered identifier names; as such, they are restricted to the following characters: [A-Z, a-z, 0-9, _:@].
  • To use a table or column name with characters not listed above, the name must be quoted using square brackets ([name]) in any SQL statement.
  • Parameter names can optionally start with the @ symbol (e.g., @p1 or @CustomerName) and cannot be quoted.
  • Strings must be quoted using single quotes (e.g., 'John Doe').

Transactions and Batching

Transactions are not currently supported.

Additionally, the driver does not support batching of SQL statements. To execute multiple commands, you can create multiple instances and execute each separately.

CData JDBC Driver for Anzo

SELECT Statements

A SELECT statement can consist of the following basic clauses. This statement can be accessed using the Odbc.Query function in the M formula language.

  • SELECT
  • INTO
  • FROM
  • JOIN
  • WHERE
  • GROUP BY
  • HAVING
  • UNION
  • ORDER BY
  • LIMIT

SELECT Syntax

The following syntax diagram outlines the syntax supported by the SQL engine of the driver:

SELECT {
  [ TOP <numeric_literal> | DISTINCT ]
  { 
    * 
    | { 
        <expression> [ [ AS ] <column_reference> ] 
        | { <table_name> | <correlation_name> } .* 
      } [ , ... ] 
  }
  [ INTO csv:// [ filename= ] <file_path> [ ;delimiter=tab ] ]
  { 
    FROM <table_reference> [ [ AS ] <identifier> ] 
  } [ , ... ]
  [ [  
      INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } 
    ] JOIN <table_reference> [ ON <search_condition> ] [ [ AS ] <identifier> ] 
  ] [ ... ] 
  [ WHERE <search_condition> ]
  [ GROUP BY <column_reference> [ , ... ]
  [ HAVING <search_condition> ]
  [ UNION [ ALL ] <select_statement> ]
  [ 
    ORDER BY 
    <column_reference> [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]
  ]
  [ 
    LIMIT <expression>
    [ 
      { OFFSET | , }
      <expression> 
    ]
  ] 
} | SCOPE_IDENTITY() 

<expression> ::=
  | <column_reference>
  | @ <parameter> 
  | ?
  | COUNT( * | { [ DISTINCT ] <expression> } )
  | { AVG | MAX | MIN | SUM | COUNT } ( <expression> ) 
  | NULLIF ( <expression> , <expression> ) 
  | COALESCE ( <expression> , ... ) 
  | CASE <expression>
      WHEN { <expression> | <search_condition> } THEN { <expression> | NULL } [ ... ]
    [ ELSE { <expression> | NULL } ]
    END 
  | <literal>
  | <sql_function> 

<search_condition> ::= 
  {
    <expression> { = | > | < | >= | <= | <> | != | LIKE | NOT LIKE | IN | NOT IN | IS NULL | IS NOT NULL | AND | OR | CONTAINS | BETWEEN } [ <expression> ]
  } [ { AND | OR } ... ] 

Examples

  1. Return all columns:
    SELECT * FROM [Anzo].[ExpandData].Events
  2. Rename a column:
    SELECT [location_displayName] AS MY_location_displayName FROM [Anzo].[ExpandData].Events
  3. Cast a column's data as a different data type:
    SELECT CAST(Reminder AS VARCHAR) AS Str_Reminder FROM [Anzo].[ExpandData].Events
  4. Search data:
    SELECT * FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'
  5. Return the number of items matching the query criteria:
    SELECT COUNT(*) AS MyCount FROM [Anzo].[ExpandData].Events 
  6. Return the number of unique items matching the query criteria:
    SELECT COUNT(DISTINCT location_displayName) FROM [Anzo].[ExpandData].Events 
  7. Return the unique items matching the query criteria:
    SELECT DISTINCT location_displayName FROM [Anzo].[ExpandData].Events 
  8. Summarize data:
    SELECT location_displayName, MAX(Reminder) FROM [Anzo].[ExpandData].Events GROUP BY location_displayName
    See Aggregate Functions for details.
  9. Retrieve data from multiple tables.
    SELECT Groups.displayName, Conversations.Topic FROM Groups, Conversations WHERE Groups.Id=Conversations.GroupId
    See JOIN Queries for details.
  10. Sort a result set in ascending order:
    SELECT Id, location_displayName FROM [Anzo].[ExpandData].Events  ORDER BY location_displayName ASC
  11. Restrict a result set to the specified number of rows:
    SELECT Id, location_displayName FROM [Anzo].[ExpandData].Events LIMIT 10 
  12. Parameterize a query to pass in inputs at execution time. This enables you to create prepared statements and mitigate SQL injection attacks.
    SELECT * FROM [Anzo].[ExpandData].Events WHERE Id = @param
See Explicitly Caching Data for information on using the SELECT statement in offline mode.

Pseudo Columns

Some input-only fields are available in SELECT statements. These fields, called pseudo columns, do not appear as regular columns in the results, yet may be specified as part of the WHERE clause. You can use pseudo columns to access additional features from Anzo.

    SELECT * FROM [Anzo].[ExpandData].Events WHERE Pseudo = '@Pseudo'
    

CData JDBC Driver for Anzo

Aggregate Functions

COUNT

Returns the number of rows matching the query criteria.

SELECT COUNT(*) FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'

COUNT

Returns the number of rows matching the query criteria.

SELECT COUNT(Reminder) FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'

COUNT(DISTINCT)

Returns the number of distinct, non-null field values matching the query criteria.

SELECT COUNT(DISTINCT Id) AS DistinctValues FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'

AVG

Returns the average of the column values.

SELECT location_displayName, AVG(Reminder) FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'  GROUP BY location_displayName

MIN

Returns the minimum column value.

SELECT MIN(Reminder), location_displayName FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB' GROUP BY location_displayName

MAX

Returns the maximum column value.

SELECT location_displayName, MAX(Reminder) FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB' GROUP BY location_displayName

SUM

Returns the total sum of the column values.

SELECT SUM(Reminder) FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'

CData JDBC Driver for Anzo

JOIN Queries

The CData JDBC Driver for Anzo supports standard SQL joins like the following examples.

Inner Join

An inner join selects only rows from both tables that match the join condition:

SELECT Groups.displayName, Conversations.Topic FROM Groups, Conversations WHERE Groups.Id=Conversations.GroupId

Left Join

A left join selects all rows in the FROM table and only matching rows in the JOIN table:

SELECT Groups.displayName, Conversations.Topic FROM Groups LEFT OUTER JOIN Conversations ON Groups.Id=Conversations.GroupId

CData JDBC Driver for Anzo

Date Literal Functions

The following date literal functions can be used to filter date fields using relative intervals. Note that while the <, >, and = operators are supported for these functions, <= and >= are not.

L_TODAY()

The current day.

  SELECT * FROM MyTable WHERE MyDateField = L_TODAY()

L_YESTERDAY()

The previous day.

  SELECT * FROM MyTable WHERE MyDateField = L_YESTERDAY()

L_TOMORROW()

The following day.

  SELECT * FROM MyTable WHERE MyDateField = L_TOMORROW()

L_LAST_WEEK()

Every day in the preceding week.

  SELECT * FROM MyTable WHERE MyDateField = L_LAST_WEEK()

L_THIS_WEEK()

Every day in the current week.

  SELECT * FROM MyTable WHERE MyDateField = L_THIS_WEEK()

L_NEXT_WEEK()

Every day in the following week.

  SELECT * FROM MyTable WHERE MyDateField = L_NEXT_WEEK()
Also available:
  • L_LAST/L_THIS/L_NEXT MONTH
  • L_LAST/L_THIS/L_NEXT QUARTER
  • L_LAST/L_THIS/L_NEXT YEAR

L_LAST_N_DAYS(n)

The previous n days, excluding the current day.

  SELECT * FROM MyTable WHERE MyDateField = L_LAST_N_DAYS(3)

L_NEXT_N_DAYS(n)

The following n days, including the current day.

  SELECT * FROM MyTable WHERE MyDateField = L_NEXT_N_DAYS(3)
Also available:
  • L_LAST/L_NEXT_90_DAYS

L_LAST_N_WEEKS(n)

Every day in every week, starting n weeks before current week, and ending in the previous week.

  SELECT * FROM MyTable WHERE MyDateField = L_LAST_N_WEEKS(3)

L_NEXT_N_WEEKS(n)

Every day in every week, starting the following week, and ending n weeks in the future.

  SELECT * FROM MyTable WHERE MyDateField = L_NEXT_N_WEEKS(3)
Also available:
  • L_LAST/L_NEXT_N_MONTHS(n)
  • L_LAST/L_NEXT_N_QUARTERS(n)
  • L_LAST/L_NEXT_N_YEARS(n)

CData JDBC Driver for Anzo

SELECT INTO Statements

You can use the SELECT INTO statement to export formatted data to a file. This statement can be accessed using the Odbc.Query function in the M formula language.

Data Export with an SQL Query

The following query exports data into a file formatted in comma-separated values (CSV):

boolean ret = stat.execute("SELECT Id, location_displayName INTO [csv://c:/[Anzo].[ExpandData].Events.txt] FROM [[Anzo].[ExpandData].Events] WHERE Id = 'Jq74mCczmFXk1tC10GB'");
System.out.println(stat.getUpdateCount()+" rows affected");
You can specify other file formats in the URI. The following example exports tab-separated values:
Statement stat = conn.createStatement();
boolean ret = stat.execute("SELECT * INTO [[Anzo].[ExpandData].Events] IN 'csv://filename=c:/[Anzo].[ExpandData].Events.csv;delimiter=tab' FROM [[Anzo].[ExpandData].Events] WHERE Id = 'Jq74mCczmFXk1tC10GB'");
System.out.println(stat.getUpdateCount()+" rows affected");

CData JDBC Driver for Anzo

SQL Functions

The driver provides functions that are similar to those that are available with most standard databases. These functions are implemented in the CData provider engine and thus are available across all data sources with the same consistent API. Three categories of functions are available: string, date, and math.

The driver interprets all SQL function inputs as either strings or column identifiers, so you need to escape all literals as strings, with single quotes. For example, contrast the SQL Server syntax and driver syntax for the DATENAME function:

  • SQL Server:
    SELECT DATENAME(yy,GETDATE())
  • driver:
    SELECT DATENAME('yy',GETDATE())

String Functions

These functions perform string manipulations and return a string value. See STRING Functions for more details.

SELECT CONCAT(firstname, space(4), lastname) FROM [Anzo].[ExpandData].Events WHERE Id = 'Jq74mCczmFXk1tC10GB'

Date Functions

These functions perform date and date time manipulations. See DATE Functions for more details.

SELECT CURRENT_TIMESTAMP() FROM [Anzo].[ExpandData].Events

Math Functions

These functions provide mathematical operations. See MATH Functions for more details.

SELECT RAND() FROM [Anzo].[ExpandData].Events

Function Parameters and Nesting SQL Functions

The driver supports column names, constants, and results of other functions as parameters to functions. The following are all valid uses of SQL functions:
SELECT CONCAT('Mr.', SPACE(2), firstname, SPACE(4), lastname) FROM [Anzo].[ExpandData].Events

CData JDBC Driver for Anzo

STRING Functions

ASCII(character_expression)

Returns the ASCII code value of the left-most character of the character expression.

  • character_expression: The character expression.

                      SELECT ASCII('0');
                      --  Result: 48
                    

CHAR(integer_expression)

Converts the integer ASCII code to the corresponding character.

  • integer_expression: The integer from 0 through 255.

                      SELECT CHAR(48);
                      -- Result: '0'
                    

CHARINDEX(expressionToFind ,expressionToSearch [,start_location ])

Returns the starting position of the specified expression in the character string.

  • expressionToFind: The character expression to find.
  • expressionToSearch: The character expression, typically a column, to search.
  • start_location: The optional character position to start searching for expressionToFind in expressionToSearch.

                      SELECT CHARINDEX('456', '0123456');
                      -- Result: 4

                      SELECT CHARINDEX('456', '0123456', 5);
                      -- Result: -1
                    

CHAR_LENGTH(character_expression),

Returns the number of UTF-8 characters present in the expression.

  • character_expression: The set of characters to be be evaluated for length.

				 SELECT CHAR_LENGTH('sample text') FROM Account LIMIT 1
				 -- Result: 11			
				

CONCAT(string_value1, string_value2 [, string_valueN])

Returns the string that is the concatenation of two or more string values.

  • string_value1: The first string to be concatenated.
  • string_value2: The second string to be concatenated.
  • *: The optional additional strings to be concatenated.

                      SELECT CONCAT('Hello, ', 'world!');
                      -- Result: 'Hello, world!'
                    

CONTAINS(expressionToSearch, expressionToFind)

Returns 1 if expressionToFind is found within expressionToSearch; otherwise, 0.

  • expressionToSearch: The character expression, typically a column, to search.
  • expressionToFind: The character expression to find.

                      SELECT CONTAINS('0123456', '456');
                      -- Result: 1

                      SELECT CONTAINS('0123456', 'Not a number');
                      -- Result: 0
                    

ENDSWITH(character_expression, character_suffix)

Returns 1 if character_expression ends with character_suffix; otherwise, 0.

  • character_expression: The character expression.
  • character_suffix: The character suffix to search for.

                      SELECT ENDSWITH('0123456', '456');
                      -- Result: 1

                      SELECT ENDSWITH('0123456', '012');
                      -- Result: 0
                    

FILESIZE(uri)

Returns the number of bytes present in the file at the specified file path.

  • uri: The path of the file to read the size from.

				SELECT FILESIZE('C:/Users/User1/Desktop/myfile.txt');
				-- Result: 23684
				

FORMAT(value [, parseFormat], format )

Returns the value formatted with the specified format.

  • value: The string to format.
  • format: The string specifying the output syntax of the date or numeric format.
  • parseFormat: The string specifying the input syntax of the date value. Not applicable to numeric types.

                      SELECT FORMAT(12.34, '#');
                      -- Result: 12

                      SELECT FORMAT(12.34, '#.###');
                      -- Result: 12.34

                      SELECT FORMAT(1234, '0.000E0');
                      -- Result: 1.234E3
                      
                      SELECT FORMAT('2019/01/01', 'yyyy-MM-dd');
                      -- Result: 2019-01-01
                      
                      SELECT FORMAT('20190101', 'yyyyMMdd', 'yyyy-MM-dd');
                      -- Result: '2019-01-01'
                    

FROM_UNIXTIME(time, issecond)

Returns a representation of the unix_timestamp argument as a value in YYYY-MM-DD HH:MM:SS expressed in the current time zone.

  • time: The time stamp value from epoch time. Milliseconds are accepted.
  • issecond: Indicates the time stamp value is milliseconds to epoch time.

                      SELECT FROM_UNIXTIME(1540495231, 1);
                      -- Result: 2018-10-25 19:20:31

                      SELECT FROM_UNIXTIME(1540495357385, 0);
                      -- Result: 2018-10-25 19:22:37
                    

HASHBYTES(algorithm, value)

Returns the hash of the input value as a byte array using the given algorithm. The supported algorithms are MD5, SHA1, SHA2_256, SHA2_512, SHA3_224, SHA3_256, SHA3_384, and SHA3_512.

  • algorithm: The algorithm to use for hashing. Must be one of MD5, SHA1, SHA2_256, SHA2_512, SHA3_224, SHA3_256, SHA3_384, or SHA3_512.
  • value: The value to hash. Must be either a string or byte array.

                      SELECT HASHBYTES('MD5', 'Test');
                      -- Result (byte array): 0x0CBC6611F5540BD0809A388DC95A615B
                    

INDEXOF(expressionToSearch, expressionToFind [,start_location ])

Returns the starting position of the specified expression in the character string.

  • expressionToSearch: The character expression, typically a column, to search.
  • expressionToFind: The character expression to find.
  • start_location: The optional character position to start searching for expressionToFind in expressionToSearch.

                      SELECT INDEXOF('0123456', '456');
                      -- Result: 4

                      SELECT INDEXOF('0123456', '456', 5);
                      -- Result: -1
                    

ISNULL ( check_expression , replacement_value )

Replaces null with the specified replacement value.

  • check_expression: The expression to be checked for null.
  • replacement_value: The expression to be returned if check_expression is null.

                      SELECT ISNULL(42, 'Was NULL');
                      -- Result: 42

                      SELECT ISNULL(NULL, 'Was NULL');
                      -- Result: 'Was NULL'
                    

JSON_AVG(json, jsonpath)

Computes the average value of a JSON array within a JSON object. The path to the array is specified in the jsonpath argument. Return value is numeric or null.

  • json: The JSON document to compute.
  • jsonpath: The JSONPath used to select the nodes. [x], [2..], [..8], or [1..12] are accepted. [x] selects all nodes.

                      SELECT JSON_AVG('[1,2,3,4,5]', '$[x]');
                      -- Result: 3

                      SELECT JSON_AVG('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[x]');
                      -- Result: 3

                      SELECT JSON_AVG('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[3..]');
                      -- Result: 4.5
                    

JSON_COUNT(json, jsonpath)

Returns the number of elements in a JSON array within a JSON object. The path to the array is specified in the jsonpath argument. Return value is numeric or null.

  • json: The JSON document to compute.
  • jsonpath: The JSONPath used to select the nodes. [x], [2..], [..8], or [1..12] are accepted. [x] selects all nodes.

                      SELECT JSON_COUNT('[1,2,3,4,5]', '$[x]');
                      -- Result: 5

                      SELECT JSON_COUNT('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[x]');
                      -- Result: 5

                      SELECT JSON_COUNT('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[3..]');
                      -- Result: 2
                    

JSON_EXTRACT(json, jsonpath)

Selects any value in a JSON array or object. The path to the array is specified in the jsonpath argument. Return value is numeric or null.

  • json: The JSON document to extract.
  • jsonpath: The XPath used to select the nodes. The JSONPath must be a string constant. The values of the nodes selected will be returned in a token-separated list.

                      SELECT JSON_EXTRACT('{"test": {"data": 1}}', '$.test');
                      -- Result: '{"data":1}'

                      SELECT JSON_EXTRACT('{"test": {"data": 1}}', '$.test.data');
                      -- Result: 1

                      SELECT JSON_EXTRACT('{"test": {"data": [1, 2, 3]}}', '$.test.data[1]');
                      -- Result: 2
                    

JSON_MAX(json, jsonpath)

Gets the maximum value in a JSON array within a JSON object. The path to the array is specified in the jsonpath argument. Return value is numeric or null.

  • json: The JSON document to compute.
  • jsonpath: The JSONPath used to select the nodes. [x], [2..], [..8], or [1..12] are accepted. [x] selects all nodes.

                      SELECT JSON_MAX('[1,2,3,4,5]', '$[x]');
                      -- Result: 5

                      SELECT JSON_MAX('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[x]');
                      -- Result: 5

                      SELECT JSON_MAX('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[..3]');
                      -- Result: 4
                    

JSON_MIN(json, jsonpath)

Gets the minimum value in a JSON array within a JSON object. The path to the array is specified in the jsonpath argument. Return value is numeric or null.

  • json: The JSON document to compute.
  • jsonpath: The JSONPath used to select the nodes. [x], [2..], [..8], or [1..12] are accepted. [x] selects all nodes.

                      SELECT JSON_MIN('[1,2,3,4,5]', '$[x]');
                      -- Result: 1

                      SELECT JSON_MIN('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[x]');
                      -- Result: 1

                      SELECT JSON_MIN('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[3..]');
                      -- Result: 4
                    

JSON_SUM(json, jsonpath)

Computes the summary value in JSON according to the JSONPath expression. Return value is numeric or null.

  • json: The JSON document to compute.
  • jsonpath: The JSONPath used to select the nodes. [x], [2..], [..8], or [1..12] are accepted. [x] selects all nodes.

                      SELECT JSON_SUM('[1,2,3,4,5]', '$[x]');
                      -- Result: 15

                      SELECT JSON_SUM('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[x]');
                      -- Result: 15

                      SELECT JSON_SUM('{"test": {"data": [1,2,3,4,5]}}', '$.test.data[3..]');
                      -- Result: 9
                    

LEFT ( character_expression , integer_expression )

Returns the specified number of characters counting from the left of the specified string.

  • character_expression: The character expression.
  • integer_expression: The positive integer that specifies how many characters will be returned counting from the left of character_expression.

                      SELECT LEFT('1234567890', 3);
                      -- Result: '123'
                    

LEN(string_expression)

Returns the number of characters of the specified string expression.

  • string_expression: The string expression.

                      SELECT LEN('12345');
                      -- Result: 5
                    

LOCATE(substring,string)

Returns an integer representing how many characters into the string the substring appears.

  • substring: The substring to find inside larger string.
  • string: The larger string that will be searched for the substring.

				SELECT LOCATE('sample','XXXXXsampleXXXXX');
				-- Result: 6
				

LOWER ( character_expression )

Returns the character expression with the uppercase character data converted to lowercase.

  • character_expression: The character expression.

                      SELECT LOWER('MIXED case');
                      -- Result: 'mixed case'
                    

LTRIM(character_expression)

Returns the character expression with leading blanks removed.

  • character_expression: The character expression.

                      SELECT LTRIM('     trimmed');
                      -- Result: 'trimmed'
                    

MASK(string_expression, mask_character [, start_index [, end_index ]])

Replaces the characters between start_index and end_index with the mask_character within the string.

  • string_expression: The string expression to be searched.
  • mask_character: The character to mask with.
  • start_index: The optional number of characters to leave unmasked at beginning of string. Defaults to 0.
  • end_index: The optional number of characters to leave unmasked at end of string. Defaults to 0.

                        SELECT MASK('1234567890','*',);
                        -- Result: '**********'
                        SELECT MASK('1234567890','*', 4);
                        -- Result: '1234******'
                        SELECT MASK('1234567890','*', 4, 2);
                        -- Result: '1234****90'  
                    

NCHAR(integer_expression)

Returns the Unicode character with the specified integer code as defined by the Unicode standard.

  • integer_expression: The integer from 0 through 255.

OCTET_LENGTH(character_expression),

Returns the number of bytes present in the expression.

  • character_expression: The set of characters to be be evaluated.

				 SELECT OCTET_LENGTH('text') FROM Account LIMIT 1
				 -- Result: 4
				

PATINDEX(pattern, expression)

Returns the starting position of the first occurrence of the pattern in the expression. Returns 0 if the pattern is not found.

  • pattern: The character expression that contains the sequence to be found. The wild-card character % can be used only at the start or end of the expression.
  • expression: The expression, typically a column, to search for the pattern.

                      SELECT PATINDEX('123%', '1234567890');
                      -- Result: 1

                      SELECT PATINDEX('%890', '1234567890');
                      -- Result: 8

                      SELECT PATINDEX('%456%', '1234567890');
                      -- Result: 4
                    

POSITION(expressionToFind IN expressionToSearch)

Returns the starting position of the specified expression in the character string.

  • expressionToFind: The character expression to find.
  • expressionToSearch: The character expression, typically a column, to search.

                      SELECT POSITION('456' IN '123456');
                      -- Result: 4

                      SELECT POSITION('x' IN '123456');
                      -- Result: 0
                    

QUOTENAME(character_string [, quote_character])

Returns a valid SQL Server-delimited identifier by adding the necessary delimiters to the specified Unicode string.

  • character_string: The string of Unicode character data. The string is limited to 128 characters. Inputs greater than 128 characters return null.
  • quote_character: The optional single character to be used as the delimiter. Can be a single quotation mark, a left or right bracket, or a double quotation mark. If quote_character is not specified brackets are used.

                      SELECT QUOTENAME('table_name');
                      -- Result: '[table_name]'

                      SELECT QUOTENAME('table_name', '"');
                      -- Result: '"table_name"'

                      SELECT QUOTENAME('table_name', '[');
                      -- Result: '[table_name]'
                    

REPLACE(string_expression, string_pattern, string_replacement)

Replaces all occurrences of a string with another string.

  • string_expression: The string expression to be searched. Can be a character or binary data type.
  • string_pattern: The substring to be found. Cannot be an empty string.
  • string_replacement: The replacement string.

                      SELECT REPLACE('1234567890', '456', '|');
                      -- Result: '123|7890'

                      SELECT REPLACE('123123123', '123', '.');
                      -- Result: '...'

                      SELECT REPLACE('1234567890', 'a', 'b');
                      -- Result: '1234567890'
                    

REPLICATE ( string_expression ,integer_expression )

Repeats the string value the specified number of times.

  • string_expression: The string to replicate.
  • integer_expression: The repeat count.

                      SELECT REPLACE('x', 5);
                      -- Result: 'xxxxx'
                    

REVERSE ( string_expression )

Returns the reverse order of the string expression.

  • string_expression: The string.

                      SELECT REVERSE('1234567890');
                      -- Result: '0987654321'
                    

RIGHT ( character_expression , integer_expression )

Returns the right part of the string with the specified number of characters.

  • character_expression: The character expression.
  • integer_expression: The positive integer that specifies how many characters of the character expression will be returned.

                      SELECT RIGHT('1234567890', 3);
                      -- Result: '890'
                    

RTRIM(character_expression)

Returns the character expression after it removes trailing blanks.

  • character_expression: The character expression.

                      SELECT RTRIM('trimmed     ');
                      -- Result: 'trimmed'
                    

SOUNDEX(character_expression)

Returns the four-character Soundex code, based on how the string sounds when spoken.

  • character_expression: The alphanumeric expression of character data.

                      SELECT SOUNDEX('smith');
                      -- Result: 'S530'
                    

SPACE(repeatcount)

Returns the string that consists of repeated spaces.

  • repeatcount: The number of spaces.

                      SELECT SPACE(5);
                      -- Result: '     '
                    

SPLIT(string, delimiter, offset)

Returns a section of the string between to delimiters.

  • string: The string to split.
  • delimiter: The character to split the string with.
  • offset: The number of the split to return. Positive numbers are treated as offsets from the left, and negative numbers are treated as offsets from the right.

                      SELECT SPLIT('a/b/c/d', '/', 1);
                      -- Result: 'a'
                      SELECT SPLIT('a/b/c/d', '/', -2);
                      -- Result: 'c'
                    

STARTSWITH(character_expression, character_prefix)

Returns 1 if character_expression starts with character_prefix; otherwise, 0.

  • character_expression: The character expression.
  • character_prefix: The character prefix to search for.

                      SELECT STARTSWITH('0123456', '012');
                      -- Result: 1

                      SELECT STARTSWITH('0123456', '456');
                      -- Result: 0
                    

STR ( float_expression [ , integer_length [ , integer_decimal ] ] )

Returns the character data converted from the numeric data. For example, STR(123.45, 6, 1) returns 123.5.

  • float_expression: The float expression.
  • length: The optional total length to return. This includes decimal point, sign, digits, and spaces. The default is 10.
  • decimal: The optional number of places to the right of the decimal point. The decimal must be less than or equal to 16.

                      SELECT STR('123.456');
                      -- Result: '123'

                      SELECT STR('123.456', 2);
                      -- Result: '**'

                      SELECT STR('123.456', 10, 2);
                      -- Result: '123.46'
                    

STUFF(character_expression , integer_start , integer_length , replaceWith_expression)

Inserts a string into another string. It deletes the specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.

  • character_expression: The string expression.
  • start: The integer value that specifies the location to start deletion and insertion. If start or length is negative, null is returned. If start is longer than the string to be modified, character_expression, null is returned.
  • length: The integer that specifies the number of characters to delete. If length is longer than character_expression, deletion occurs up to the last character in replaceWith_expression.
  • replaceWith_expression: The expression of character data that will replace length characters of character_expression beginning at the start value.

                      SELECT STUFF('1234567890', 3, 2, 'xx');
                      -- Result: '12xx567890'
                    

SUBSTRING(string_value FROM start FOR length)

Returns the part of the string with the specified length; starts at the specified index.

  • string_value: The character string.
  • start: The positive integer that specifies the start index of characters to return.
  • length: Optional. The positive integer that specifies how many characters will be returned.

                      SELECT SUBSTRING('1234567890' FROM 3 FOR 2);
                      -- Result: '34'

                      SELECT SUBSTRING('1234567890' FROM 3);
                      -- Result: '34567890'
                    

TOSTRING(string_value1)

Converts the value of this instance to its equivalent string representation.

  • string_value1: The string to be converted.

                      SELECT TOSTRING(123);
                      -- Result: '123'

                      SELECT TOSTRING(123.456);
                      -- Result: '123.456'

                      SELECT TOSTRING(null);
                      -- Result: ''
                    

TRIM(trimspec trimchar FROM string_value)

Returns the character expression with leading and/or trailing blanks removed.

  • trimspec: Optional. If included must be one of the keywords BOTH, LEADING or TRAILING.
  • trimchar: Optional. If included should be a one-character string value.
  • string_value: The string value to trim.

                      SELECT TRIM('     trimmed     ');
                      -- Result: 'trimmed'

                      SELECT TRIM(LEADING FROM '     trimmed     ');
                      -- Result: 'trimmed     '

                      SELECT TRIM('-' FROM '-----trimmed-----');
                      -- Result: 'trimmed'

                      SELECT TRIM(BOTH '-' FROM '-----trimmed-----');
                      -- Result: 'trimmed'

                      SELECT TRIM(TRAILING '-' FROM '-----trimmed-----');
                      -- Result: '-----trimmed'
                    

UNICODE(ncharacter_expression)

Returns the integer value defined by the Unicode standard of the first character of the input expression.

  • ncharacter_expression: The Unicode character expression.

UPPER ( character_expression )

Returns the character expression with lowercase character data converted to uppercase.

  • character_expression: The character expression.

                      SELECT UPPER('MIXED case');
                      -- Result: 'MIXED CASE'
                    

XML_EXTRACT(xml, xpath [, separator])

Extracts an XML document using the specified XPath to flatten the XML. A comma is used to separate the outputs by default, but this can be changed by specifying the third parameter.

  • xml: The XML document to extract.
  • xpath: The XPath used to select the nodes. The nodes selected will be returned in a token-separated list.
  • separator: The optional token used to separate the items in the flattened response. If this is not specified, the separator will be a comma.

                      SELECT XML_EXTRACT('<vowels><ch>a</ch><ch>e</ch><ch>i</ch><ch>o</ch><ch>u</ch></vowels>', '/vowels/ch');
                      -- Result: 'a,e,i,o,u'

                      SELECT XML_EXTRACT('<vowels><ch>a</ch><ch>e</ch><ch>i</ch><ch>o</ch><ch>u</ch></vowels>', '/vowels/ch', ';');
                      -- Result: 'a;e;i;o;u'
                    

CData JDBC Driver for Anzo

DATE Functions

CURRENT_DATE()

Returns the current date value.

                  SELECT CURRENT_DATE();
                  -- Result: 2018-02-01
                

CURRENT_TIMESTAMP()

Returns the current time stamp of the database system as a datetime value. This value is equal to GETDATE and SYSDATETIME, and is always in the local timezone.

                  SELECT CURRENT_TIMESTAMP();
                  -- Result: 2018-02-01 03:04:05
                

DATEADD (datepart , integer_number , date [, dateformat])

Returns the datetime value that results from adding the specified number (a signed integer) to the specified date part of the date.

  • datepart: The part of the date to add the specified number to. The valid values and abbreviations are year (yy, yyyy), quarter (qq, q), month (mm, m), dayofyear (dy, y), day (dd, d), week (wk, ww), weekday (dw), hour (hh), minute (mi, n), second (ss, s), and millisecond (ms).
  • number: The number to be added.
  • date: The expression of the datetime data type.
  • dateformat: The optional output date format.

                  SELECT DATEADD('d', 5, '2018-02-01');
                  -- Result: 2018-02-06

                  SELECT DATEADD('hh', 5, '2018-02-01 00:00:00');
                  -- Result: 2018-02-01 05:00:00
                

DATEDIFF ( datepart , startdate , enddate )

Returns the difference (a signed integer) of the specified time interval between the specified start date and end date.

  • datepart: The part of the date that is the time interval of the difference between the start date and end date. The valid values and abbreviations are day (dd, d), hour (hh), minute (mi, n), second (ss, s), and millisecond (ms).
  • startdate: The datetime expression of the start date.
  • enddate: The datetime expression of the end date.

                  SELECT DATEDIFF('d', '2018-02-01', '2018-02-10');
                  -- Result: 9

                  SELECT DATEDIFF('hh', '2018-02-01 00:00:00', '2018-02-01 12:00:00');
                  -- Result: 12
                

DATEFROMPARTS(integer_year, integer_month, integer_day)

Returns the datetime value for the specified year, month, and day.

  • year: The integer expression specifying the year.
  • month: The integer expression specifying the month.
  • day: The integer expression specifying the day.

                    SELECT DATEFROMPARTS(2018, 2, 1);
                    -- Result: 2018-02-01
                  

DATENAME(datepart , date)

Returns the character string that represents the specified date part of the specified date.

  • datepart: The part of the date to return. The valid values and abbreviations are year (yy, yyyy), quarter (qq, q), month (mm, m), dayofyear (dy, y), day (dd, d), week (wk, ww), weekday (dw), hour (hh), minute (mi, n), second (ss, s), millisecond (ms), microsecond (mcs), nanosecond (ns), and TZoffset (tz).
  • date: The datetime expression.

                     SELECT DATENAME('yy', '2018-02-01');
                     -- Result: '2018'

                     SELECT DATENAME('dw', '2018-02-01');
                     -- Result: 'Thursday'
                   

DATEPART(datepart, date [,integer_datefirst])

Returns a character string that represents the specified date part of the specified date.

  • datepart: The part of the date to return. The valid values and abbreviations are year (yy, yyyy), quarter (qq, q), month (mm, m), dayofyear (dy, y), day (dd, d), week (wk, ww), weekday (dw), hour (hh), minute (mi, n), second (ss, s), millisecond (ms), microsecond (mcs), nanosecond (ns), TZoffset (tz), ISODOW, ISO_WEEK (isoweek, isowk,isoww), and ISOYEAR.
  • date: The datetime string.
  • datefirst: The optional integer representing the first day of the week. The default is 7, Sunday.

                    SELECT DATEPART('yy', '2018-02-01');
                    -- Result: 2018

                    SELECT DATEPART('dw', '2018-02-01');
                    -- Result: 5
                  

DATETIME2FROMPARTS(integer_year, integer_month, integer_day, integer_hour, integer_minute, integer_seconds, integer_fractions, integer_precision)

Returns the datetime value for the specified date parts.

  • year: The integer expression specifying the year.
  • month: The integer expression specifying the month.
  • day: The integer expression specifying the day.
  • hour: The integer expression specifying the hour.
  • minute: The integer expression specifying the minute.
  • seconds: The integer expression specifying the seconds.
  • fractions: The integer expression specifying the fractions of the second.
  • precision: The integer expression specifying the precision of the fraction.

                    SELECT DATETIME2FROMPARTS(2018, 2, 1, 1, 2, 3, 456, 3);
                    -- Result: 2018-02-01 01:02:03.456
                  

DATETIMEFROMPARTS(integer_year, integer_month, integer_day, integer_hour, integer_minute, integer_seconds, integer_milliseconds)

Returns the datetime value for the specified date parts.

  • year: The integer expression specifying the year.
  • month: The integer expression specifying the month.
  • day: The integer expression specifying the day.
  • hour: The integer expression specifying the hour.
  • minute: The integer expression specifying the minute.
  • seconds: The integer expression specifying the seconds.
  • milliseconds: The integer expression specifying the milliseconds.

                    SELECT DATETIMEFROMPARTS(2018, 2, 1, 1, 2, 3, 456);
                    -- Result: 2018-02-01 01:02:03.456
                  

DATE_TRUNC(date, datepart)

Truncates the date to the precision of the given date part. Modeled after the Oracle TRUNC function.

  • date: The datetime string that specifies the date.
  • datepart: Refer to the Oracle documentation for valid datepart syntax.

				    SELECT DATE_TRUNC('05-04-2005', 'YY');
                    -- Result: '1/1/2005'
					
                    SELECT DATE_TRUNC('05-04-2005', 'MM');
                    -- Result: '5/1/2005'                    
                  

DATE_TRUNC2(datepart, date, [weekday])

Truncates the date to the precision of the given date part. Modeled after the PostgreSQL date_trunc function.

  • datepart: One of 'millennium', 'century', 'decade', 'year', 'quarter', 'month', 'week', 'day', 'hour', 'minute' or 'second'.
  • date: The datetime string that specifies the date.
  • weekday: The optional day of the week to use as the first day for 'week'. One of 'sunday', 'monday', etc.

                    SELECT DATE_TRUNC2('year', '2020-02-04');
                    -- Result: '2020-01-01'

                    SELECT DATE_TRUNC2('week', '2020-02-04', 'monday');
                    -- Result: '2020-02-02', which is the previous Monday
                  

DAY(date)

Returns the integer that specifies the day component of the specified date.

  • date: The datetime string that specifies the date.

                    SELECT DAY('2018-02-01');
                    -- Result: 1
                  

DAYOFMONTH(date)

Returns the day of the month of the given date part.
  • date: The datetime string that specifies the date.

				  SELECT DAYOFMONTH('04/15/2000');
				  -- Result: 15
				  

DAYOFWEEK(date)

Returns the day of the week of the given date part.
  • date: The datetime string that specifies the date.

				  SELECT DAYOFWEEK('04/15/2000');
				  -- Result: 7
				  

DAYOFYEAR(date)

Returns the day of the year of the given date part.
  • date: The datetime string that specifies the date.

				  SELECT DAYOFYEAR('04/15/2000');
				  -- Result: 106
				  

EOMONTH(date [, integer_month_to_add ]) or LAST_DAY(date)

Returns the last day of the month that contains the specified date with an optional offset.

  • date: The datetime expression specifying the date for which to return the last day of the month.
  • integer_month_to_add: The optional integer expression specifying the number of months to add to the date before calculating the end of the month.

                  SELECT EOMONTH('2018-02-01');
                  -- Result: 2018-02-28
                  
                  SELECT LAST_DAY('2018-02-01');
                  -- Result: 2018-02-28

                  SELECT EOMONTH('2018-02-01', 2);
                  -- Result: 2018-04-30
                

FDWEEK(date)

Returns the first day of the week of the given date part.
  • date: The datetime string that specifies the date.

				  SELECT FDWEEK('02-08-2018');
				  -- Result: 2/4/2018
				  

FDMONTH(date)

Returns the first day of the month of the given date part.
  • date: The datetime string that specifies the date.

				  SELECT FDMONTH('02-08-2018');
				  -- Result: 2/1/2018
				  

FDQUARTER(date)

Returns the first day of the quarter of the given date part.
  • date: The datetime string that specifies the date.

				  SELECT FDQUARTER('05-08-2018');
				  -- Result: 4/1/2018
				  

FILEMODIFIEDTIME(uri)

Returns the time stamp associated with the Date Modified of the relevant file.

  • uri: An absolute path pointing to a file on the local file system.

				 SELECT FILEMODIFIEDTIME('C:/Documents/myfile.txt');
				 -- Result: 6/25/2019 10:06:58 AM
				 

FROM_DAYS(datevalue)

Returns a date derived from the number of days after 1582-10-15 (based upon the Gregorian calendar). This will be equivalent to the MYSQL FROM_DAYS function.

  • datevalue: A integer value representing the number of days since 1582-10-15.

				SELECT FROM_DAYS(736000);
				-- Result: 2/6/2015
				

GETDATE()

Returns the current time stamp of the database system as a datetime value. This value is equal to CURRENT_TIMESTAMP and SYSDATETIME, and is always in the local timezone.

                  SELECT GETDATE();
                  -- Result: 2018-02-01 03:04:05
                

GETUTCDATE()

Returns the current time stamp of the database system formatted as a UTC datetime value. This value is equal to SYSUTCDATETIME.

                  SELECT GETUTCDATE();
                  -- For example, if the local timezone is Eastern European Time (GMT+2)
                  -- Result: 2018-02-01 05:04:05
                

HOUR(date)

Returns the hour component from the provided datetime.

  • date: The datetime string that specifies the date.

				SELECT HOUR('02-02-2020 11:30:00');
				-- Result: 11
				

ISDATE(date, [date_format])

Returns 1 if the value is a valid date, time, or datetime value; otherwise, 0.

  • date: The datetime string.
  • date_format: The optional datetime format.

                      SELECT ISDATE('2018-02-01', 'yyyy-MM-dd');
                      -- Result: 1

                      SELECT ISDATE('Not a date');
                      -- Result: 0
                    

LAST_WEEK()

Returns a time stamp equivalent to exactly one week before the current date.

				SELECT LAST_WEEK();	//Assume the date is 3/17/2020	
				-- Result: 3/10/2020
				

LAST_MONTH()

Returns a time stamp equivalent to exactly one month before the current date.

				SELECT LAST_MONTH(); //Assume the date is 3/17/2020	
				-- Result: 2/17/2020
				

LAST_YEAR()

Returns a time stamp equivalent to exactly one year before the current date.

				SELECT LAST_YEAR();	//Assume the date is 3/17/2020	
				-- Result: 3/10/2019
				

LDWEEK(date)

Returns the last day of the provided week.

  • date: The datetime string.

				SELECT LDWEEK('02-02-2020');
				-- Result: 2/8/2020
				

LDMONTH(date)

Returns the last day of the provided month.

  • date: The datetime string.

				SELECT LDMONTH('02-02-2020');
				-- Result: 2/29/2020
				

LDQUARTER(date)

Returns the last day of the provided quarter.

  • date: The datetime string.

				SELECT LDQUARTER('02-02-2020');
				-- Result: 3/31/2020
				

MAKEDATE(year, days)

Returns a date value from a year and a number of days.

  • year: The year
  • days: The number of days into the year. Value must be greater than 0.

          SELECT MAKEDATE(2020, 1);
          -- Result: 2020-01-01
        

MINUTE(date)

Returns the minute component from the provided datetime.

  • date: The datetime string that specifies the date.

				SELECT MINUTE('02-02-2020 11:15:00');
				-- Result: 15
				

MONTH(date)

Returns the month component from the provided datetime.

  • date: The datetime string that specifies the date.

				SELECT MONTH('02-02-2020');
				-- Result: 2
				

QUARTER(date)

Returns the quarter associated with the provided datetime.

  • date: The datetime string that specifies the date.

				SELECT QUARTER('02-02-2020');
				-- Result: 1
				

SECOND(date)

Returns the second component from the provided datetime.

  • date: The datetime string that specifies the date.

				SELECT SECOND('02-02-2020 11:15:23');
				-- Result: 23
				

SMALLDATETIMEFROMPARTS(integer_year, integer_month, integer_day, integer_hour, integer_minute)

Returns the datetime value for the specified date and time.

  • year: The integer expression specifying the year.
  • month: The integer expression specifying the month.
  • day: The integer expression specifying the day.
  • hour: The integer expression specifying the hour.
  • minute: The integer expression specifying the minute.

                      SELECT SMALLDATETIMEFROMPARTS(2018, 2, 1, 1, 2);
                      -- Result: 2018-02-01 01:02:00
                    

STRTODATE(string,format)

Parses the provided string value and returns the corresponding datetime.

  • string: The string value to be converted to datetime format.
  • format: A format string which describes how to interpret the first string input. Follows standard Oracle date format syntax. A few special formats are available as well, including UNIX, UNIXMILIS, TICKS, and FILETICKS.

				SELECT STRTODATE('03*04*2020','dd*MM*yyyy');
				-- Result: 4/3/2020
				

SYSDATETIME()

Returns the current time stamp as a datetime value of the database system. It is equal to GETDATE and CURRENT_TIMESTAMP, and is always in the local timezone.

                  SELECT SYSDATETIME();
                  -- Result: 2018-02-01 03:04:05
                

SYSUTCDATETIME()

Returns the current system date and time as a UTC datetime value. It is equal to GETUTCDATE.

                  SELECT SYSUTCDATETIME();
                  -- For example, if the local timezone is Eastern European Time (GMT+2)
                  -- Result: 2018-02-01 05:04:05
                

TIMEFROMPARTS(integer_hour, integer_minute, integer_seconds, integer_fractions, integer_precision)

Returns the time value for the specified time and with the specified precision.

  • hour: The integer expression specifying the hour.
  • minute: The integer expression specifying the minute.
  • seconds: The integer expression specifying the seconds.
  • fractions: The integer expression specifying the fractions of the second.
  • precision : The integer expression specifying the precision of the fraction.

                      SELECT TIMEFROMPARTS(1, 2, 3, 456, 3);
                      -- Result: 01:02:03.456
                    

TO_DAYS(date)

Returns the number of days since 0000-00-01. This will only return a value for dates on or after 1582-10-15 (based upon the Gregorian calendar). This will be equivalent to the MYSQL TO_DAYS function.

  • date: The datetime string that specifies the date.

				SELECT TO_DAYS('02-06-2015');
				-- Result: 736000
				

WEEK(date)

Returns the week (of the year) associated with the provided datetime.

  • date: The datetime string that specifies the date.

				SELECT WEEK('02-17-2020 11:15:23');
				-- Result: 8
				

YEAR(date)

Returns the integer that specifies the year of the specified date.

  • date: The datetime string.

                      SELECT YEAR('2018-02-01');
                      -- Result: 2018
                    

CData JDBC Driver for Anzo

MATH Functions

ABS ( numeric_expression )

Returns the absolute (positive) value of the specified numeric expression.

  • numeric_expression: The expression of an indeterminate numeric data type except for the bit data type.

                      SELECT ABS(15);
                      -- Result: 15

                      SELECT ABS(-15);
                      -- Result: 15
                    

ACOS ( float_expression )

Returns the arc cosine, the angle in radians whose cosine is the specified float expression.

  • float_expression: The float expression that specifies the cosine of the angle to be returned. Values outside the range from -1 to 1 return null.

                      SELECT ACOS(0.5);
                      -- Result: 1.0471975511966
                    

ASIN ( float_expression )

Returns the arc sine, the angle in radians whose sine is the specified float expression.

  • float_expression: The float expression that specifies the sine of the angle to be returned. Values outside the range from -1 to 1 return null.

                      SELECT ASIN(0.5);
                      -- Result: 0.523598775598299
                    

ATAN ( float_expression )

Returns the arc tangent, the angle in radians whose tangent is the specified float expression.

  • float_expression: The float expression that specifies the tangent of the angle to be returned.

                      SELECT ATAN(10);
                      -- Result: 1.47112767430373
                    

ATN2 ( float_expression1 , float_expression2 )

Returns the angle in radians between the positive x-axis and the ray from the origin to the point (y, x) where x and y are the values of the two specified float expressions.

  • float_expression1: The float expression that is the y-coordinate.
  • float_expression2: The float expression that is the x-coordinate.

                      SELECT ATN2(1, 1);
                      -- Result: 0.785398163397448
                    

CEILING ( numeric_expression ) or CEIL( numeric_expression )

Returns the smallest integer greater than or equal to the specified numeric expression.

  • numeric_expression: The expression of an indeterminate numeric data type except for the bit data type.

                      SELECT CEILING(1.3);
                      -- Result: 2

                      SELECT CEILING(1.5);
                      -- Result: 2

                      SELECT CEILING(1.7);
                      -- Result: 2
                    

COS ( float_expression )

Returns the trigonometric cosine of the specified angle in radians in the specified expression.

  • float_expression: The float expression of the specified angle in radians.

                      SELECT COS(1);
                      -- Result: 0.54030230586814
                    

COT ( float_expression )

Returns the trigonometric cotangent of the angle in radians specified by float_expression.

  • float_expression: The float expression of the angle in radians.

                      SELECT COT(1);
                      -- Result: 0.642092615934331
                    

DEGREES ( numeric_expression )

Returns the angle in degrees for the angle specified in radians.

  • numeric_expression: The angle in radians, an expression of an indeterminate numeric data type except for the bit data type.

                      SELECT DEGREES(3.1415926);
                      -- Result: 179.999996929531
                    

EXP ( float_expression )

Returns the exponential value of the specified float expression. For example, EXP(LOG(20)) is 20.

  • float_expression: The float expression.

                      SELECT EXP(2);
                      -- Result: 7.38905609893065
                    

EXPR ( expression )

Evaluates the expression.

  • expression: The expression. Operators allowed are +, -, *, /, ==, !=, >, <, >=, and <=.

                      SELECT EXPR('1 + 2 * 3');
                      -- Result: 7

                      SELECT EXPR('1 + 2 * 3 == 7');
                      -- Result: true
                    

FLOOR ( numeric_expression )

Returns the largest integer less than or equal to the numeric expression.

  • numeric_expression: The expression of an indeterminate numeric data type except for the bit data type.

                      SELECT FLOOR(1.3);
                      -- Result: 1

                      SELECT FLOOR(1.5);
                      -- Result: 1

                      SELECT FLOOR(1.7);
                      -- Result: 1
                    

GREATEST(int1,int2,....)

Returns the greatest of the supplied integers.

				SELECT GREATEST(3,5,8,10,1)
				-- Result: 10			
				

HEX(value)

Returns a the equivalent hex for the input value.

  • value: A string or numerical value to be converted into hex.

				SELECT HEX(866849198);
				-- Result: 33AB11AE
				
				SELECT HEX('Sample Text');
				-- Result: 53616D706C652054657874
				

LEAST(int1,int2,....)

Returns the least of the supplied integers.

				SELECT LEAST(3,5,8,10,1)
				-- Result: 1			
				

LOG ( float_expression [, base ] )

Returns the natural logarithm of the specified float expression.

  • float_expression: The float expression.
  • base: The optional integer argument that sets the base for the logarithm.

                      SELECT LOG(7.3890560);
                      -- Result: 1.99999998661119
                    

LOG10 ( float_expression )

Returns the base-10 logarithm of the specified float expression.

  • float_expression: The expression of type float.

                      SELECT LOG10(10000);
                      -- Result: 4
                    

MOD(dividend,divisor)

Returns the integer value associated with the remainder when dividing the dividend by the divisor.

  • dividend: The number to take the modulus of.
  • divisor: The number to divide the dividend by when determining the modulus.

				SELECT MOD(10,3);
				-- Result: 1
				

NEGATE(real_number)

Returns the opposite to the real number input.

  • real_number: The real number to find the opposite of.

				SELECT NEGATE(10);
				-- Result: -10
				
				SELECT NEGATE(-12.4)
				--Result: 12.4
				

PI ( )

Returns the constant value of pi.

                  SELECT PI()
                  -- Result: 3.14159265358979 
                

POWER ( float_expression , y )

Returns the value of the specified expression raised to the specified power.

  • float_expression: The float expression.
  • y: The power to raise float_expression to.

                      SELECT POWER(2, 10);
                      -- Result: 1024

                      SELECT POWER(2, -2);
                      -- Result: 0.25
                    

RADIANS ( float_expression )

Returns the angle in radians of the angle in degrees.

  • float_expression: The degrees of the angle as a float expression.

                      SELECT RADIANS(180);
                      -- Result: 3.14159265358979
                    

RAND ( [ integer_seed ] )

Returns a pseudorandom float value from 0 through 1, exclusive.

  • seed: The optional integer expression that specifies the seed value. If seed is not specified, a seed value at random will be assigned.

                      SELECT RAND();
                      -- This result may be different, since the seed is randomized
                      -- Result: 0.873159630165044

                      SELECT RAND(1);
                      -- This result will always be the same, since the seed is constant
                      -- Result: 0.248668584157093
                    

ROUND ( numeric_expression [ ,integer_length] [ ,function ] )

Returns the numeric value rounded to the specified length or precision.

  • numeric_expression: The expression of a numeric data type.
  • length: The optional precision to round the numeric expression to. When this is ommitted, the default behavior will be to round to the nearest whole number.
  • function: The optional type of operation to perform. When the function parameter is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.

                      SELECT ROUND(1.3, 0);
                      -- Result: 1

                      SELECT ROUND(1.55, 1);
                      -- Result: 1.6

                      SELECT ROUND(1.7, 0, 0);
                      -- Result: 2

                      SELECT ROUND(1.7, 0, 1);
                      -- Result: 1
                      
                      SELECT ROUND (1.24);
                      -- Result: 1.0
                    

SIGN ( numeric_expression )

Returns the positive sign (1), 0, or negative sign (-1) of the specified expression.

  • numeric_expression: The expression of an indeterminate data type except for the bit data type.

                      SELECT SIGN(0);
                      -- Result: 0

                      SELECT SIGN(10);
                      -- Result: 1

                      SELECT SIGN(-10);
                      -- Result: -1
                    

SIN ( float_expression )

Returns the trigonometric sine of the angle in radians.

  • float_expression: The float expression specifying the angle in radians.

                     SELECT SIN(1);
                     -- Result: 0.841470984807897
                    

SQRT ( float_expression )

Returns the square root of the specified float value.

  • float_expression: The expression of type float.

                      SELECT SQRT(100);
                      -- Result: 10
                    

SQUARE ( float_expression )

Returns the square of the specified float value.

  • float_expression: The expression of type float.

                      SELECT SQUARE(10);
                      -- Result: 100

                      SELECT SQUARE(-10);
                      -- Result: 100
                    

TAN ( float_expression )

Returns the tangent of the input expression.

  • float_expression: The expression of type float.

                      SELECT TAN(1);
                      -- Result: 1.5574077246549
                    

TRUNC(decimal_number,precision)

Returns the supplied decimal number truncated to have the supplied decimal precision.

  • decimal_number: The decimal value to truncate.
  • precision: The number of decimal places to truncate the decimal number to.

				SELECT TRUNC(10.3423,2);
				-- Result: 10.34
				

CData JDBC Driver for Anzo

INSERT Statements

To create new records, use INSERT statements. This statement can be accessed using the Odbc.Query function in the M formula language.

INSERT Syntax

The INSERT statement specifies the columns to be inserted and the new column values. You can specify the column values in a comma-separated list in the VALUES clause, as shown in the following example:

INSERT INTO <table_name> 
( <column_reference> [ , ... ] )
VALUES 
( { <expression> | NULL } [ , ... ] ) 
  

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>
You can use the executeUpdate method of the Statement and PreparedStatement classes to execute data manipulation commands and retrieve the rows affected. To retrieve the Id of the last inserted record use getGeneratedKeys. Additionally, set the RETURN_GENERATED_KEYS flag of the Statement class when you call prepareStatement.
String cmd = "INSERT INTO [Anzo].[ExpandData].Events (location_displayName) VALUES (?)";
PreparedStatement pstmt = connection.prepareStatement(cmd,Statement.RETURN_GENERATED_KEYS);
pstmt.setString(1, "Zenburger");
int count = pstmt.executeUpdate();
System.out.println(count+" rows were affected");
ResultSet rs = pstmt.getGeneratedKeys();
while(rs.next()){	  
  System.out.println(rs.getString("Id"));
}
connection.close();	

CData JDBC Driver for Anzo

UPDATE Statements

To modify existing records, use UPDATE statements. This statement can be accessed using the Odbc.Query function in the M formula language.

Update Syntax

The UPDATE statement takes as input a comma-separated list of columns and new column values as name-value pairs in the SET clause, as shown in the following example:

UPDATE <table_name> SET { <column_reference> = <expression> } [ , ... ] WHERE { Id = <expression>  } [ { AND | OR } ... ] 

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>
You can use the executeUpdate method of the Statement or PreparedStatement classes to execute data manipulation commands and retrieve the rows affected, as shown in the following example:
String cmd = "UPDATE [Anzo].[ExpandData].Events SET location_displayName='Zenburger' WHERE Id = ?";
PreparedStatement pstmt = connection.prepareStatement(cmd);
pstmt.setString(1, "Jq74mCczmFXk1tC10GB");
int count = pstmt.executeUpdate();
System.out.println(count + " rows were affected");
connection.close();

CData JDBC Driver for Anzo

DELETE Statements

To delete information from a table, use DELETE statements. This statement can be accessed using the Odbc.Query function in the M formula language.

DELETE Syntax

The DELETE statement requires the table name in the FROM clause and the row's primary key in the WHERE clause, as shown in the following example:

<delete_statement> ::= DELETE FROM <table_name> WHERE { Id = <expression> } [ { AND | OR } ... ]

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>
You can use the executeUpdate method of the Statement or PreparedStatement classes to execute data manipulation commands and retrieve the number of affected rows, as shown in the following example:
Connection connection = DriverManager.getConnection("jdbc:anzo:User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;",);
String cmd = "DELETE FROM [Anzo].[ExpandData].Events WHERE Id = ?";
PreparedStatement pstmt = connection.prepareStatement(cmd);
pstmt.setString(1, "Jq74mCczmFXk1tC10GB");
int count=pstmt.executeUpdate();
connection.close();

CData JDBC Driver for Anzo

CACHE Statements

When caching is enabled, CACHE statements provide complete control over the data that is cached and the table to which it is cached. The CACHE statement executes the SELECT statement specified and caches its results to a table with the same name in the cache database or to table specified in <cached_table_name>. The driver updates or inserts rows to the cache depending on whether or not they already exist in the cache, so the primary key, which is used to identify existing rows, must be included in the selected columns.

This statement can be accessed using the Odbc.Query function in the M formula language.

See Caching Data for more information on different caching strategies.

CACHE Statement Syntax

The cache statement may include the following options that alter its behavior:

CACHE [ <cached_table_name> ] [ WITH TRUNCATE | AUTOCOMMIT | SCHEMA ONLY | DROP EXISTING | ALTER SCHEMA ] <select_statement> 

WITH TRUNCATE

If this option is set, the driver removes existing rows in the cache table before adding the selected rows. Use this option if you want to refresh the entire cache table but keep its existing schema.

AUTOCOMMIT

If this option is set, the driver commits each row individually. Use this option if you want to ignore the rows that could not be cached due to some reason. By default, the entire result set is cached as a single transaction.

DROP EXISTING

If this option is set, the driver drops the existing cache table before caching the new results. Use this option if you want to refresh the entire cache table, including its schema.

SCHEMA ONLY

If this option is set, the driver creates the cache table based on the SELECT statement without executing the query.

ALTER SCHEMA

If this option is set, the driver alters the schema of the existing table in the cache if it does not match the schema of the SELECT statement. This option results in new columns or dropped columns, if the schema of the SELECT statement does not match the cached table.

Common Queries

Use the following cache statement to cache all rows of a table:

CACHE SELECT * FROM [Anzo].[ExpandData].Events

Use the following cache statement to cache all rows of a table into the cache table Cached[Anzo].[ExpandData].Events:

CACHE CachedEvents SELECT * FROM [Anzo].[ExpandData].Events

Use the following cache statement for incremental caching. The DateModified column may not exist in all tables. The cache statement shows how incremental caching would work if there were such a column. Also, notice that, in this case, the WITH TRUNCATE and DROP EXISTING options are specifically omitted, which would have deleted all existing rows.

CACHE CachedEvents SELECT * FROM [Anzo].[ExpandData].Events WHERE DateModified > '2013-04-04'

Use the following cache statements to create a table with all available columns that will then cache only a few of them. The sequence of statements cache only Id and location_displayName even though the cache table Cached[Anzo].[ExpandData].Events has all the columns in [Anzo].[ExpandData].Events.

CACHE CachedEvents SCHEMA ONLY SELECT * FROM [Anzo].[ExpandData].Events
CACHE CachedEvents SELECT Id, location_displayName FROM [Anzo].[ExpandData].Events

CData JDBC Driver for Anzo

EXECUTE Statements

To execute stored procedures, you can use EXECUTE or EXEC statements. This statement can be accessed using the Odbc.Query function in the M formula language.

EXEC and EXECUTE assign stored procedure inputs, referenced by name, to values or parameter names.

Stored Procedure Syntax

To execute a stored procedure as an SQL statement, use the following syntax:

 
{ EXECUTE | EXEC } <stored_proc_name> 
{
  [ @ ] <input_name> = <expression>
} [ , ... ]

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>

Example Statements

Reference stored procedure inputs by name:

EXECUTE my_proc @second = 2, @first = 1, @third = 3;

Execute a parameterized stored procedure statement:

EXECUTE my_proc second = @p1, first = @p2, third = @p3; 

CData JDBC Driver for Anzo

Data Model

The CData JDBC Driver for Anzo models Anzo entities in relational Views, or read-only tables. The table definitions are dynamically obtained from the Anzo source you connect to. Any changes in the metadata, such as added or removed columns or changes in data type, can be loaded by reconnecting.

Views

The driver models the entity sets and singletons described in the API's service metadata document as Tables. Since Anzo is currently read-only, tables can only be read from at this time.

CData JDBC Driver for Anzo

System Tables

You can query the system tables described in this section to access schema information, information on data source functionality, and batch operation statistics.

Schema Tables

The following tables return database metadata for Anzo:

Data Source Tables

The following tables return information about how to connect to and query the data source:

  • sys_connection_props: Returns information on the available connection properties.
  • sys_sqlinfo: Describes the SELECT queries that the driver can offload to the data source.

Query Information Tables

The following table returns query statistics for data modification queries:

  • sys_identity: Returns information about batch operations or single updates.

CData JDBC Driver for Anzo

sys_catalogs

Lists the available databases.

The following query retrieves all databases determined by the connection string:

SELECT * FROM sys_catalogs

Columns

Name Type Description
CatalogName String The database name.

CData JDBC Driver for Anzo

sys_schemas

Lists the available schemas.

The following query retrieves all available schemas:

          SELECT * FROM sys_schemas
          

Columns

Name Type Description
CatalogName String The database name.
SchemaName String The schema name.

CData JDBC Driver for Anzo

sys_tables

Lists the available tables.

The following query retrieves the available tables and views:

          SELECT * FROM sys_tables
          

Columns

Name Type Description
CatalogName String The database containing the table or view.
SchemaName String The schema containing the table or view.
TableName String The name of the table or view.
TableType String The table type (table or view).
Description String A description of the table or view.
IsUpdateable Boolean Whether the table can be updated.

CData JDBC Driver for Anzo

sys_tablecolumns

Describes the columns of the available tables and views.

The following query returns the columns and data types for the [Anzo].[ExpandData].Events table:

SELECT ColumnName, DataTypeName FROM sys_tablecolumns WHERE TableName='Events' AND CatalogName='Anzo' AND SchemaName='ExpandData'

Columns

Name Type Description
CatalogName String The name of the database containing the table or view.
SchemaName String The schema containing the table or view.
TableName String The name of the table or view containing the column.
ColumnName String The column name.
DataTypeName String The data type name.
DataType Int32 An integer indicating the data type. This value is determined at run time based on the environment.
Length Int32 The storage size of the column.
DisplaySize Int32 The designated column's normal maximum width in characters.
NumericPrecision Int32 The maximum number of digits in numeric data. The column length in characters for character and date-time data.
NumericScale Int32 The column scale or number of digits to the right of the decimal point.
IsNullable Boolean Whether the column can contain null.
Description String A brief description of the column.
Ordinal Int32 The sequence number of the column.
IsAutoIncrement String Whether the column value is assigned in fixed increments.
IsGeneratedColumn String Whether the column is generated.
IsHidden Boolean Whether the column is hidden.
IsArray Boolean Whether the column is an array.

CData JDBC Driver for Anzo

sys_procedures

Lists the available stored procedures.

The following query retrieves the available stored procedures:

          SELECT * FROM sys_procedures
          

Columns

Name Type Description
CatalogName String The database containing the stored procedure.
SchemaName String The schema containing the stored procedure.
ProcedureName String The name of the stored procedure.
Description String A description of the stored procedure.
ProcedureType String The type of the procedure, such as PROCEDURE or FUNCTION.

CData JDBC Driver for Anzo

sys_procedureparameters

Describes stored procedure parameters.

The following query returns information about all of the input parameters for the SendMail stored procedure:

SELECT * FROM sys_procedureparameters WHERE ProcedureName='SendMail' AND Direction=1 OR Direction=2

Columns

Name Type Description
CatalogName String The name of the database containing the stored procedure.
SchemaName String The name of the schema containing the stored procedure.
ProcedureName String The name of the stored procedure containing the parameter.
ColumnName String The name of the stored procedure parameter.
Direction Int32 An integer corresponding to the type of the parameter: input (1), input/output (2), or output(4). input/output type parameters can be both input and output parameters.
DataTypeName String The name of the data type.
DataType Int32 An integer indicating the data type. This value is determined at run time based on the environment.
Length Int32 The number of characters allowed for character data. The number of digits allowed for numeric data.
NumericPrecision Int32 The maximum precision for numeric data. The column length in characters for character and date-time data.
NumericScale Int32 The number of digits to the right of the decimal point in numeric data.
IsNullable Boolean Whether the parameter can contain null.
IsRequired Boolean Whether the parameter is required for execution of the procedure.
IsArray Boolean Whether the parameter is an array.
Description String The description of the parameter.
Ordinal Int32 The index of the parameter.

CData JDBC Driver for Anzo

sys_keycolumns

Describes the primary and foreign keys.

The following query retrieves the primary key for the [Anzo].[ExpandData].Events table:

         SELECT * FROM sys_keycolumns WHERE IsKey='True' AND TableName='Events' AND CatalogName='Anzo' AND SchemaName='ExpandData'
          

Columns

Name Type Description
CatalogName String The name of the database containing the key.
SchemaName String The name of the schema containing the key.
TableName String The name of the table containing the key.
ColumnName String The name of the key column.
IsKey Boolean Whether the column is a primary key in the table referenced in the TableName field.
IsForeignKey Boolean Whether the column is a foreign key referenced in the TableName field.
PrimaryKeyName String The name of the primary key.
ForeignKeyName String The name of the foreign key.
ReferencedCatalogName String The database containing the primary key.
ReferencedSchemaName String The schema containing the primary key.
ReferencedTableName String The table containing the primary key.
ReferencedColumnName String The column name of the primary key.

CData JDBC Driver for Anzo

sys_foreignkeys

Describes the foreign keys.

The following query retrieves all foreign keys which refer to other tables:

         SELECT * FROM sys_foreignkeys WHERE ForeignKeyType = 'FOREIGNKEY_TYPE_IMPORT'
          

Columns

Name Type Description
CatalogName String The name of the database containing the key.
SchemaName String The name of the schema containing the key.
TableName String The name of the table containing the key.
ColumnName String The name of the key column.
PrimaryKeyName String The name of the primary key.
ForeignKeyName String The name of the foreign key.
ReferencedCatalogName String The database containing the primary key.
ReferencedSchemaName String The schema containing the primary key.
ReferencedTableName String The table containing the primary key.
ReferencedColumnName String The column name of the primary key.
ForeignKeyType String Designates whether the foreign key is an import (points to other tables) or export (referenced from other tables) key.

CData JDBC Driver for Anzo

sys_indexes

Describes the available indexes. By filtering on indexes, you can write more selective queries with faster query response times.

The following query retrieves all indexes that are not primary keys:

          SELECT * FROM sys_indexes WHERE IsPrimary='false'
          

Columns

Name Type Description
CatalogName String The name of the database containing the index.
SchemaName String The name of the schema containing the index.
TableName String The name of the table containing the index.
IndexName String The index name.
ColumnName String The name of the column associated with the index.
IsUnique Boolean True if the index is unique. False otherwise.
IsPrimary Boolean True if the index is a primary key. False otherwise.
Type Int16 An integer value corresponding to the index type: statistic (0), clustered (1), hashed (2), or other (3).
SortOrder String The sort order: A for ascending or D for descending.
OrdinalPosition Int16 The sequence number of the column in the index.

CData JDBC Driver for Anzo

sys_connection_props

Returns information on the available connection properties and those set in the connection string.

When querying this table, the config connection string should be used:

jdbc:cdata:anzo:config:

This connection string enables you to query this table without a valid connection.

The following query retrieves all connection properties that have been set in the connection string or set through a default value:

SELECT * FROM sys_connection_props WHERE Value <> ''

Columns

Name Type Description
Name String The name of the connection property.
ShortDescription String A brief description.
Type String The data type of the connection property.
Default String The default value if one is not explicitly set.
Values String A comma-separated list of possible values. A validation error is thrown if another value is specified.
Value String The value you set or a preconfigured default.
Required Boolean Whether the property is required to connect.
Category String The category of the connection property.
IsSessionProperty String Whether the property is a session property, used to save information about the current connection.
Sensitivity String The sensitivity level of the property. This informs whether the property is obfuscated in logging and authentication forms.
PropertyName String A camel-cased truncated form of the connection property name.
Ordinal Int32 The index of the parameter.
CatOrdinal Int32 The index of the parameter category.
Hierarchy String Shows dependent properties associated that need to be set alongside this one.
Visible Boolean Informs whether the property is visible in the connection UI.
ETC String Various miscellaneous information about the property.

CData JDBC Driver for Anzo

sys_sqlinfo

Describes the SELECT query processing that the driver can offload to the data source.

Collaborative Query Processing

When working with data sources that do not support SQL-92, you can query the sys_sqlinfo view to determine the query capabilities of the underlying APIs, expressed in SQL syntax. The driver offloads as much of the SELECT statement processing as possible to the server and then processes the rest of the query in memory.

See SupportEnhancedSQL for more information on how the driver circumvents API limitations with in-memory client-side processing. See SQL Compliance for SQL syntax details.

Discovering the Data Source's SELECT Capabilities

Below is an example data set of SQL capabilities. The following result set indicates the SELECT functionality that the driver can offload to the data source or process client side. Your data source may support additional SQL syntax. Some aspects of SELECT functionality are returned in a comma-separated list if supported; otherwise, the column contains NO.

NameDescriptionPossible Values
AGGREGATE_FUNCTIONSSupported aggregation functions.AVG, COUNT, MAX, MIN, SUM, DISTINCT
COUNTWhether COUNT function is supported.YES, NO
IDENTIFIER_QUOTE_OPEN_CHARThe opening character used to escape an identifier.[
IDENTIFIER_QUOTE_CLOSE_CHARThe closing character used to escape an identifier.]
SUPPORTED_OPERATORSA list of supported SQL operators.=, >, <, >=, <=, <>, !=, LIKE, NOT LIKE, IN, NOT IN, IS NULL, IS NOT NULL, AND, OR
GROUP_BYWhether GROUP BY is supported, and, if so, the degree of support.NO, NO_RELATION, EQUALS_SELECT, SQL_GB_COLLATE
OJ_CAPABILITIESThe supported varieties of outer joins supported.NO, LEFT, RIGHT, FULL, INNER, NOT_ORDERED, ALL_COMPARISON_OPS
OUTER_JOINSWhether outer joins are supported.YES, NO
SUBQUERIESWhether subqueries are supported, and, if so, the degree of support.NO, COMPARISON, EXISTS, IN, CORRELATED_SUBQUERIES, QUANTIFIED
STRING_FUNCTIONSSupported string functions.LENGTH, CHAR, LOCATE, REPLACE, SUBSTRING, RTRIM, LTRIM, RIGHT, LEFT, UCASE, SPACE, SOUNDEX, LCASE, CONCAT, ASCII, REPEAT, OCTET, BIT, POSITION, INSERT, TRIM, UPPER, REGEXP, LOWER, DIFFERENCE, CHARACTER, SUBSTR, STR, REVERSE, PLAN, UUIDTOSTR, TRANSLATE, TRAILING, TO, STUFF, STRTOUUID, STRING, SPLIT, SORTKEY, SIMILAR, REPLICATE, PATINDEX, LPAD, LEN, LEADING, KEY, INSTR, INSERTSTR, HTML, GRAPHICAL, CONVERT, COLLATION, CHARINDEX, BYTE
NUMERIC_FUNCTIONSSupported numeric functions.ABS, ACOS, ASIN, ATAN, ATAN2, CEILING, COS, COT, EXP, FLOOR, LOG, MOD, SIGN, SIN, SQRT, TAN, PI, RAND, DEGREES, LOG10, POWER, RADIANS, ROUND, TRUNCATE
TIMEDATE_FUNCTIONSSupported date/time functions.NOW, CURDATE, DAYOFMONTH, DAYOFWEEK, DAYOFYEAR, MONTH, QUARTER, WEEK, YEAR, CURTIME, HOUR, MINUTE, SECOND, TIMESTAMPADD, TIMESTAMPDIFF, DAYNAME, MONTHNAME, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, EXTRACT
REPLICATION_SKIP_TABLESIndicates tables skipped during replication.
REPLICATION_TIMECHECK_COLUMNSA string array containing a list of columns which will be used to check for (in the given order) to use as a modified column during replication.
IDENTIFIER_PATTERNString value indicating what string is valid for an identifier.
SUPPORT_TRANSACTIONIndicates if the provider supports transactions such as commit and rollback.YES, NO
DIALECTIndicates the SQL dialect to use.
KEY_PROPERTIESIndicates the properties which identify the uniform database.
SUPPORTS_MULTIPLE_SCHEMASIndicates if multiple schemas may exist for the provider.YES, NO
SUPPORTS_MULTIPLE_CATALOGSIndicates if multiple catalogs may exist for the provider.YES, NO
DATASYNCVERSIONThe CData Data Sync version needed to access this driver.Standard, Starter, Professional, Enterprise
DATASYNCCATEGORYThe CData Data Sync category of this driver.Source, Destination, Cloud Destination
SUPPORTSENHANCEDSQLWhether enhanced SQL functionality beyond what is offered by the API is supported.TRUE, FALSE
SUPPORTS_BATCH_OPERATIONSWhether batch operations are supported.YES, NO
SQL_CAPAll supported SQL capabilities for this driver.SELECT, INSERT, DELETE, UPDATE, TRANSACTIONS, ORDERBY, OAUTH, ASSIGNEDID, LIMIT, LIKE, BULKINSERT, COUNT, BULKDELETE, BULKUPDATE, GROUPBY, HAVING, AGGS, OFFSET, REPLICATE, COUNTDISTINCT, JOINS, DROP, CREATE, DISTINCT, INNERJOINS, SUBQUERIES, ALTER, MULTIPLESCHEMAS, GROUPBYNORELATION, OUTERJOINS, UNIONALL, UNION, UPSERT, GETDELETED, CROSSJOINS, GROUPBYCOLLATE, MULTIPLECATS, FULLOUTERJOIN, MERGE, JSONEXTRACT, BULKUPSERT, SUM, SUBQUERIESFULL, MIN, MAX, JOINSFULL, XMLEXTRACT, AVG, MULTISTATEMENTS, FOREIGNKEYS, CASE, LEFTJOINS, COMMAJOINS, WITH, LITERALS, RENAME, NESTEDTABLES, EXECUTE, BATCH, BASIC, INDEX
PREFERRED_CACHE_OPTIONSA string value specifies the preferred cacheOptions.
ENABLE_EF_ADVANCED_QUERYIndicates if the driver directly supports advanced queries coming from Entity Framework. If not, queries will be handled client side.YES, NO
PSEUDO_COLUMNSA string array indicating the available pseudo columns.
MERGE_ALWAYSIf the value is true, The Merge Mode is forcibly executed in Data Sync.TRUE, FALSE
REPLICATION_MIN_DATE_QUERYA select query to return the replicate start datetime.
REPLICATION_MIN_FUNCTIONAllows a provider to specify the formula name to use for executing a server side min.
REPLICATION_START_DATEAllows a provider to specify a replicate startdate.
REPLICATION_MAX_DATE_QUERYA select query to return the replicate end datetime.
REPLICATION_MAX_FUNCTIONAllows a provider to specify the formula name to use for executing a server side max.
IGNORE_INTERVALS_ON_INITIAL_REPLICATEA list of tables which will skip dividing the replicate into chunks on the initial replicate.
CHECKCACHE_USE_PARENTIDIndicates whether the CheckCache statement should be done against the parent key column.TRUE, FALSE
CREATE_SCHEMA_PROCEDURESIndicates stored procedures that can be used for generating schema files.

The following query retrieves the operators that can be used in the WHERE clause:

SELECT * FROM sys_sqlinfo WHERE Name='SUPPORTED_OPERATORS'
Note that individual tables may have different limitations or requirements on the WHERE clause; refer to the Data Model section for more information.

Columns

Name Type Description
NAME String A component of SQL syntax, or a capability that can be processed on the server.
VALUE String Detail on the supported SQL or SQL syntax.

CData JDBC Driver for Anzo

sys_identity

Returns information about attempted modifications.

The following query retrieves the Ids of the modified rows in a batch operation:

         SELECT * FROM sys_identity
          

Columns

Name Type Description
Id String The database-generated Id returned from a data modification operation.
Batch String An identifier for the batch. 1 for a single operation.
Operation String The result of the operation in the batch: INSERTED, UPDATED, or DELETED.
Message String SUCCESS or an error message if the update in the batch failed.

CData JDBC Driver for Anzo

Data Type Mapping

Data Type Mappings

The driver maps types from the data source to the corresponding data type available in the schema. The table below documents these mappings.

Anzo (OData V4) CData Schema
Edm.Binary binary
Edm.Boolean bool
Edm.Date datetime
Edm.DateTimeOffset datetime
Edm.Decimal decimal
Edm.Double double
Edm.Guid guid
Edm.Int32 int
Edm.String string
Edm.TimeOfDay time

CData JDBC Driver for Anzo

Connection String Options

The connection string properties are the various options that can be used to establish a connection. This section provides a complete list of the options you can configure in the connection string for this provider. Click the links for further details.

For more information on establishing a connection, see Establishing a Connection.

Authentication


PropertyDescription
URLURL to the Anzo endpoint.
UserThe Anzo user account used to authenticate.
PasswordThe password used to authenticate the user.

SSL


PropertyDescription
SSLServerCertThe certificate to be accepted from the server when connecting using TLS/SSL.

Firewall


PropertyDescription
FirewallTypeThe protocol used by a proxy-based firewall.
FirewallServerThe name or IP address of a proxy-based firewall.
FirewallPortThe TCP port for a proxy-based firewall.
FirewallUserThe user name to use to authenticate with a proxy-based firewall.
FirewallPasswordA password used to authenticate to a proxy-based firewall.

Proxy


PropertyDescription
ProxyAutoDetectThis indicates whether to use the system proxy settings or not. This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.
ProxyServerThe hostname or IP address of a proxy to route HTTP traffic through.
ProxyPortThe TCP port the ProxyServer proxy is running on.
ProxyAuthSchemeThe authentication type to use to authenticate to the ProxyServer proxy.
ProxyUserA user name to be used to authenticate to the ProxyServer proxy.
ProxyPasswordA password to be used to authenticate to the ProxyServer proxy.
ProxySSLTypeThe SSL type to use when connecting to the ProxyServer proxy.
ProxyExceptionsA semicolon separated list of destination hostnames or IPs that are exempt from connecting through the ProxyServer .

Logging


PropertyDescription
LogfileA filepath which designates the name and location of the log file.
VerbosityThe verbosity level that determines the amount of detail included in the log file.
LogModulesCore modules to be included in the log file.
MaxLogFileSizeA string specifying the maximum size in bytes for a log file (for example, 10 MB).
MaxLogFileCountA string specifying the maximum file count of log files.

Schema


PropertyDescription
LocationA path to the directory that contains the schema files defining tables, views, and stored procedures.
BrowsableSchemasThis property restricts the schemas reported to a subset of the available schemas. For example, BrowsableSchemas=SchemaA,SchemaB,SchemaC.
ViewsRestricts the views reported to a subset of the available tables. For example, Views=ViewA,ViewB,ViewC.

Caching


PropertyDescription
AutoCacheAutomatically caches the results of SELECT queries into a cache database specified by either CacheLocation or both of CacheConnection and CacheProvider .
CacheDriverThe database driver to be used to cache data.
CacheConnectionThe connection string for the cache database. This property is always used in conjunction with CacheProvider . Setting both properties will override the value set for CacheLocation for caching data.
CacheLocationSpecifies the path to the cache when caching to a file.
CacheToleranceThe tolerance for stale data in the cache specified in seconds when using AutoCache .
OfflineUse offline mode to get the data from the cache instead of the live source.
CacheMetadataThis property determines whether or not to cache the table metadata to a file store.

Miscellaneous


PropertyDescription
BatchSizeThe maximum size of each batch operation to submit.
ConnectionLifeTimeThe maximum lifetime of a connection in seconds. Once the time has elapsed, the connection object is disposed.
ConnectOnOpenThis property specifies whether to connect to the Anzo when the connection is opened.
CustomHeadersOther headers as determined by the user (optional).
CustomUrlParamsThe custom query string to be included in the request.
MaxRowsLimits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.
OtherThese hidden properties are used only in specific use cases.
PagesizeThe maximum number of results to return per page from Anzo.
PoolIdleTimeoutThe allowed idle time for a connection before it is closed.
PoolMaxSizeThe maximum connections in the pool.
PoolMinSizeThe minimum number of connections in the pool.
PoolWaitTimeThe max seconds to wait for an available connection.
PseudoColumnsThis property indicates whether or not to include pseudo columns as columns to the table.
SupportEnhancedSQLThis property enhances SQL functionality beyond what can be supported through the API directly, by enabling in-memory client-side processing.
TimeoutThe value in seconds until the timeout error is thrown, canceling the operation.
UseConnectionPoolingThis property enables connection pooling.
CData JDBC Driver for Anzo

Authentication

This section provides a complete list of the Authentication properties you can configure in the connection string for this provider.


PropertyDescription
URLURL to the Anzo endpoint.
UserThe Anzo user account used to authenticate.
PasswordThe password used to authenticate the user.
CData JDBC Driver for Anzo

URL

URL to the Anzo endpoint.

Data Type

string

Default Value

""

Remarks

URL to the Anzo endpoint. For example:

http://35.184.41.230:8080/dataondemand/MyData

CData JDBC Driver for Anzo

User

The Anzo user account used to authenticate.

Data Type

string

Default Value

""

Remarks

Together with Password, this field is used to authenticate against the Anzo server.

CData JDBC Driver for Anzo

Password

The password used to authenticate the user.

Data Type

string

Default Value

""

Remarks

The User and Password are together used to authenticate with the server.

CData JDBC Driver for Anzo

SSL

This section provides a complete list of the SSL properties you can configure in the connection string for this provider.


PropertyDescription
SSLServerCertThe certificate to be accepted from the server when connecting using TLS/SSL.
CData JDBC Driver for Anzo

SSLServerCert

The certificate to be accepted from the server when connecting using TLS/SSL.

Data Type

string

Default Value

""

Remarks

If using a TLS/SSL connection, this property can be used to specify the TLS/SSL certificate to be accepted from the server. Any other certificate that is not trusted by the machine is rejected.

This property can take the following forms:

Description Example
A full PEM Certificate (example shortened for brevity) -----BEGIN CERTIFICATE----- MIIChTCCAe4CAQAwDQYJKoZIhv......Qw== -----END CERTIFICATE-----
A path to a local file containing the certificate C:\cert.cer
The public key (example shortened for brevity) -----BEGIN RSA PUBLIC KEY----- MIGfMA0GCSq......AQAB -----END RSA PUBLIC KEY-----
The MD5 Thumbprint (hex values can also be either space or colon separated) ecadbdda5a1529c58a1e9e09828d70e4
The SHA1 Thumbprint (hex values can also be either space or colon separated) 34a929226ae0819f2ec14b4a3d904f801cbb150d

If not specified, any certificate trusted by the machine is accepted.

Certificates are validated as trusted by the machine based on the System's trust store. The trust store used is the 'javax.net.ssl.trustStore' value specified for the system. If no value is specified for this property, Java's default trust store is used (for example, JAVA_HOME\lib\security\cacerts).

Use '*' to signify to accept all certificates. Note that this is not recommended due to security concerns.

CData JDBC Driver for Anzo

Firewall

This section provides a complete list of the Firewall properties you can configure in the connection string for this provider.


PropertyDescription
FirewallTypeThe protocol used by a proxy-based firewall.
FirewallServerThe name or IP address of a proxy-based firewall.
FirewallPortThe TCP port for a proxy-based firewall.
FirewallUserThe user name to use to authenticate with a proxy-based firewall.
FirewallPasswordA password used to authenticate to a proxy-based firewall.
CData JDBC Driver for Anzo

FirewallType

The protocol used by a proxy-based firewall.

Possible Values

NONE, TUNNEL, SOCKS4, SOCKS5

Data Type

string

Default Value

"NONE"

Remarks

This property specifies the protocol that the driver will use to tunnel traffic through the FirewallServer proxy. Note that by default, the driver connects to the system proxy; to disable this behavior and connect to one of the following proxy types, set ProxyAutoDetect to false.

Type Default Port Description
TUNNEL 80 When this is set, the driver opens a connection to Anzo and traffic flows back and forth through the proxy.
SOCKS4 1080 When this is set, the driver sends data through the SOCKS 4 proxy specified by FirewallServer and FirewallPort and passes the FirewallUser value to the proxy, which determines if the connection request should be granted.
SOCKS5 1080 When this is set, the driver sends data through the SOCKS 5 proxy specified by FirewallServer and FirewallPort. If your proxy requires authentication, set FirewallUser and FirewallPassword to credentials the proxy recognizes.

To connect to HTTP proxies, use ProxyServer and ProxyPort. To authenticate to HTTP proxies, use ProxyAuthScheme, ProxyUser, and ProxyPassword.

CData JDBC Driver for Anzo

FirewallServer

The name or IP address of a proxy-based firewall.

Data Type

string

Default Value

""

Remarks

This property specifies the IP address, DNS name, or host name of a proxy allowing traversal of a firewall. The protocol is specified by FirewallType: Use FirewallServer with this property to connect through SOCKS or do tunneling. Use ProxyServer to connect to an HTTP proxy.

Note that the driver uses the system proxy by default. To use a different proxy, set ProxyAutoDetect to false.

CData JDBC Driver for Anzo

FirewallPort

The TCP port for a proxy-based firewall.

Data Type

int

Default Value

0

Remarks

This specifies the TCP port for a proxy allowing traversal of a firewall. Use FirewallServer to specify the name or IP address. Specify the protocol with FirewallType.

CData JDBC Driver for Anzo

FirewallUser

The user name to use to authenticate with a proxy-based firewall.

Data Type

string

Default Value

""

Remarks

The FirewallUser and FirewallPassword properties are used to authenticate against the proxy specified in FirewallServer and FirewallPort, following the authentication method specified in FirewallType.

CData JDBC Driver for Anzo

FirewallPassword

A password used to authenticate to a proxy-based firewall.

Data Type

string

Default Value

""

Remarks

This property is passed to the proxy specified by FirewallServer and FirewallPort, following the authentication method specified by FirewallType.

CData JDBC Driver for Anzo

Proxy

This section provides a complete list of the Proxy properties you can configure in the connection string for this provider.


PropertyDescription
ProxyAutoDetectThis indicates whether to use the system proxy settings or not. This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.
ProxyServerThe hostname or IP address of a proxy to route HTTP traffic through.
ProxyPortThe TCP port the ProxyServer proxy is running on.
ProxyAuthSchemeThe authentication type to use to authenticate to the ProxyServer proxy.
ProxyUserA user name to be used to authenticate to the ProxyServer proxy.
ProxyPasswordA password to be used to authenticate to the ProxyServer proxy.
ProxySSLTypeThe SSL type to use when connecting to the ProxyServer proxy.
ProxyExceptionsA semicolon separated list of destination hostnames or IPs that are exempt from connecting through the ProxyServer .
CData JDBC Driver for Anzo

ProxyAutoDetect

This indicates whether to use the system proxy settings or not. This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.

Data Type

bool

Default Value

false

Remarks

This takes precedence over other proxy settings, so you'll need to set ProxyAutoDetect to FALSE in order use custom proxy settings.

NOTE: When this property is set to True, the proxy used is determined as follows:

  • A search from the JVM properties (http.proxy, https.proxy, socksProxy, etc.) is performed.
  • In the case that the JVM properties don't exist, a search from java.home/lib/net.properties is performed.
  • In the case that java.net.useSystemProxies is set to True, a search from the SystemProxy is performed.
  • In Windows only, an attempt is made to retrieve these properties from the Internet Options in the registry.

To connect to an HTTP proxy, see ProxyServer. For other proxies, such as SOCKS or tunneling, see FirewallType.

CData JDBC Driver for Anzo

ProxyServer

The hostname or IP address of a proxy to route HTTP traffic through.

Data Type

string

Default Value

""

Remarks

The hostname or IP address of a proxy to route HTTP traffic through. The driver can use the HTTP, Windows (NTLM), or Kerberos authentication types to authenticate to an HTTP proxy.

If you need to connect through a SOCKS proxy or tunnel the connection, see FirewallType.

By default, the driver uses the system proxy. If you need to use another proxy, set ProxyAutoDetect to false.

CData JDBC Driver for Anzo

ProxyPort

The TCP port the ProxyServer proxy is running on.

Data Type

int

Default Value

80

Remarks

The port the HTTP proxy is running on that you want to redirect HTTP traffic through. Specify the HTTP proxy in ProxyServer. For other proxy types, see FirewallType.

CData JDBC Driver for Anzo

ProxyAuthScheme

The authentication type to use to authenticate to the ProxyServer proxy.

Possible Values

BASIC, DIGEST, NONE, NEGOTIATE, NTLM, PROPRIETARY

Data Type

string

Default Value

"BASIC"

Remarks

This value specifies the authentication type to use to authenticate to the HTTP proxy specified by ProxyServer and ProxyPort.

Note that the driver will use the system proxy settings by default, without further configuration needed; if you want to connect to another proxy, you will need to set ProxyAutoDetect to false, in addition to ProxyServer and ProxyPort. To authenticate, set ProxyAuthScheme and set ProxyUser and ProxyPassword, if needed.

The authentication type can be one of the following:

  • BASIC: The driver performs HTTP BASIC authentication.
  • DIGEST: The driver performs HTTP DIGEST authentication.
  • NEGOTIATE: The driver retrieves an NTLM or Kerberos token based on the applicable protocol for authentication.
  • PROPRIETARY: The driver does not generate an NTLM or Kerberos token. You must supply this token in the Authorization header of the HTTP request.

If you need to use another authentication type, such as SOCKS 5 authentication, see FirewallType.

CData JDBC Driver for Anzo

ProxyUser

A user name to be used to authenticate to the ProxyServer proxy.

Data Type

string

Default Value

""

Remarks

The ProxyUser and ProxyPassword options are used to connect and authenticate against the HTTP proxy specified in ProxyServer.

You can select one of the available authentication types in ProxyAuthScheme. If you are using HTTP authentication, set this to the user name of a user recognized by the HTTP proxy. If you are using Windows or Kerberos authentication, set this property to a user name in one of the following formats:

user@domain
domain\user

CData JDBC Driver for Anzo

ProxyPassword

A password to be used to authenticate to the ProxyServer proxy.

Data Type

string

Default Value

""

Remarks

This property is used to authenticate to an HTTP proxy server that supports NTLM (Windows), Kerberos, or HTTP authentication. To specify the HTTP proxy, you can set ProxyServer and ProxyPort. To specify the authentication type, set ProxyAuthScheme.

If you are using HTTP authentication, additionally set ProxyUser and ProxyPassword to HTTP proxy.

If you are using NTLM authentication, set ProxyUser and ProxyPassword to your Windows password. You may also need these to complete Kerberos authentication.

For SOCKS 5 authentication or tunneling, see FirewallType.

By default, the driver uses the system proxy. If you want to connect to another proxy, set ProxyAutoDetect to false.

CData JDBC Driver for Anzo

ProxySSLType

The SSL type to use when connecting to the ProxyServer proxy.

Possible Values

AUTO, ALWAYS, NEVER, TUNNEL

Data Type

string

Default Value

"AUTO"

Remarks

This property determines when to use SSL for the connection to an HTTP proxy specified by ProxyServer. This value can be AUTO, ALWAYS, NEVER, or TUNNEL. The applicable values are the following:

AUTODefault setting. If the URL is an HTTPS URL, the driver will use the TUNNEL option. If the URL is an HTTP URL, the component will use the NEVER option.
ALWAYSThe connection is always SSL enabled.
NEVERThe connection is not SSL enabled.
TUNNELThe connection is through a tunneling proxy. The proxy server opens a connection to the remote host and traffic flows back and forth through the proxy.

CData JDBC Driver for Anzo

ProxyExceptions

A semicolon separated list of destination hostnames or IPs that are exempt from connecting through the ProxyServer .

Data Type

string

Default Value

""

Remarks

The ProxyServer is used for all addresses, except for addresses defined in this property. Use semicolons to separate entries.

Note that the driver uses the system proxy settings by default, without further configuration needed; if you want to explicitly configure proxy exceptions for this connection, you need to set ProxyAutoDetect = false, and configure ProxyServer and ProxyPort. To authenticate, set ProxyAuthScheme and set ProxyUser and ProxyPassword, if needed.

CData JDBC Driver for Anzo

Logging

This section provides a complete list of the Logging properties you can configure in the connection string for this provider.


PropertyDescription
LogfileA filepath which designates the name and location of the log file.
VerbosityThe verbosity level that determines the amount of detail included in the log file.
LogModulesCore modules to be included in the log file.
MaxLogFileSizeA string specifying the maximum size in bytes for a log file (for example, 10 MB).
MaxLogFileCountA string specifying the maximum file count of log files.
CData JDBC Driver for Anzo

Logfile

A filepath which designates the name and location of the log file.

Data Type

string

Default Value

""

Remarks

Once this property is set, the driver will populate the log file as it carries out various tasks, such as when authentication is performed or queries are executed. If the specified file doesn't already exist, it will be created.

Connection strings and version information are also logged, though connection properties containing sensitive information are masked automatically.

If a relative filepath is supplied, the location of the log file will be resolved based on the path found in the Location connection property.

For more control over what is written to the log file, you can adjust the Verbosity property.

Log contents are categorized into several modules. You can show/hide individual modules using the LogModules property.

To edit the maximum size of a single logfile before a new one is created, see MaxLogFileSize.

If you would like to place a cap on the number of logfiles generated, use MaxLogFileCount.

Java Logging

Java logging is also supported. To enable Java logging, set Logfile to:

Logfile=JAVALOG://myloggername

As in the above sample, JAVALOG:// is a required prefix to use Java logging, and you will substitute your own Logger.

The supplied Logger's getLogger method is then called, using the supplied value to create the Logger instance. If a logging instance already exists, it will reference the existing instance.

When Java logging is enabled, the Verbosity will now correspond to specific logging levels.

CData JDBC Driver for Anzo

Verbosity

The verbosity level that determines the amount of detail included in the log file.

Data Type

string

Default Value

"1"

Remarks

The verbosity level determines the amount of detail that the driver reports to the Logfile. Verbosity levels from 1 to 5 are supported. These are detailed in the Logging page.

CData JDBC Driver for Anzo

LogModules

Core modules to be included in the log file.

Data Type

string

Default Value

""

Remarks

Only the modules specified (separated by ';') will be included in the log file. By default all modules are included.

See the Logging page for an overview.

CData JDBC Driver for Anzo

MaxLogFileSize

A string specifying the maximum size in bytes for a log file (for example, 10 MB).

Data Type

string

Default Value

"100MB"

Remarks

When the limit is hit, a new log is created in the same folder with the date and time appended to the end. The default limit is 100 MB. Values lower than 100 kB will use 100 kB as the value instead.

Adjust the maximum number of logfiles generated with MaxLogFileCount.

CData JDBC Driver for Anzo

MaxLogFileCount

A string specifying the maximum file count of log files.

Data Type

int

Default Value

-1

Remarks

When the limit is hit, a new log is created in the same folder with the date and time appended to the end and the oldest log file will be deleted.

The minimum supported value is 2. A value of 0 or a negative value indicates no limit on the count.

Adjust the maximum size of the logfiles generated with MaxLogFileSize.

CData JDBC Driver for Anzo

Schema

This section provides a complete list of the Schema properties you can configure in the connection string for this provider.


PropertyDescription
LocationA path to the directory that contains the schema files defining tables, views, and stored procedures.
BrowsableSchemasThis property restricts the schemas reported to a subset of the available schemas. For example, BrowsableSchemas=SchemaA,SchemaB,SchemaC.
ViewsRestricts the views reported to a subset of the available tables. For example, Views=ViewA,ViewB,ViewC.
CData JDBC Driver for Anzo

Location

A path to the directory that contains the schema files defining tables, views, and stored procedures.

Data Type

string

Default Value

"%APPDATA%\\CData\\Anzo Data Provider\\Schema"

Remarks

Note for Power BI Gateway users: When running the driver through the PowerBI Gateway, the Location property will need to be set to an absolute path. This is because the Gateway runs under a Windows service account.

The path to a directory which contains the schema files for the driver (.rsd files for tables and views, .rsb files for stored procedures). The folder location can be a relative path from the location of the executable. The Location property is only needed if you want to customize definitions (for example, change a column name, ignore a column, and so on) or extend the data model with new tables, views, or stored procedures.

If left unspecified, the default location is "%APPDATA%\\CData\\Anzo Data Provider\\Schema" with %APPDATA% being set to the user's configuration directory:

Platform %APPDATA%
Windows The value of the APPDATA environment variable
Mac ~/Library/Application Support
Linux ~/.config

CData JDBC Driver for Anzo

BrowsableSchemas

This property restricts the schemas reported to a subset of the available schemas. For example, BrowsableSchemas=SchemaA,SchemaB,SchemaC.

Data Type

string

Default Value

""

Remarks

Listing the schemas from databases can be expensive. Providing a list of schemas in the connection string improves the performance.

CData JDBC Driver for Anzo

Views

Restricts the views reported to a subset of the available tables. For example, Views=ViewA,ViewB,ViewC.

Data Type

string

Default Value

""

Remarks

Listing the views from some databases can be expensive. Providing a list of views in the connection string improves the performance of the driver.

This property can also be used as an alternative to automatically listing views if you already know which ones you want to work with and there would otherwise be too many to work with.

Specify the views you want in a comma-separated list. Each view should be a valid SQL identifier with any special characters escaped using square brackets, double-quotes or backticks. For example, Views=ViewA,[ViewB/WithSlash],WithCatalog.WithSchema.`ViewC With Space`.

Note that when connecting to a data source with multiple schemas or catalogs, you will need to provide the fully qualified name of the table in this property, as in the last example here, to avoid ambiguity between tables that exist in multiple catalogs or schemas.

CData JDBC Driver for Anzo

Caching

This section provides a complete list of the Caching properties you can configure in the connection string for this provider.


PropertyDescription
AutoCacheAutomatically caches the results of SELECT queries into a cache database specified by either CacheLocation or both of CacheConnection and CacheProvider .
CacheDriverThe database driver to be used to cache data.
CacheConnectionThe connection string for the cache database. This property is always used in conjunction with CacheProvider . Setting both properties will override the value set for CacheLocation for caching data.
CacheLocationSpecifies the path to the cache when caching to a file.
CacheToleranceThe tolerance for stale data in the cache specified in seconds when using AutoCache .
OfflineUse offline mode to get the data from the cache instead of the live source.
CacheMetadataThis property determines whether or not to cache the table metadata to a file store.
CData JDBC Driver for Anzo

AutoCache

Automatically caches the results of SELECT queries into a cache database specified by either CacheLocation or both of CacheConnection and CacheProvider .

Data Type

bool

Default Value

false

Remarks

When AutoCache = true, the driver automatically maintains a cache of your table's data in the database of your choice.

Setting the Caching Database

When AutoCache = true, the driver caches to a simple, file-based cache. You can configure its location or cache to a different database with the following properties:

See Also

  • CacheMetadata: This property reduces the amount of metadata that crosses the network by persisting table schemas retrieved from the Anzo metadata. Metadata then needs to be retrieved only once instead of every connection.
  • Explicitly Caching Data: This section provides more examples of using AutoCache in Offline mode.
  • CACHE Statements: You can use the CACHE statement to persist any SELECT query, as well as manage the cache; for example, refreshing schemas.

CData JDBC Driver for Anzo

CacheDriver

The database driver to be used to cache data.

Data Type

string

Default Value

""

Remarks

You can cache to any database for which you have a JDBC driver, including CData JDBC drivers.

The cache database is determined based on the CacheDriver and CacheConnection properties. The CacheDriver is the name of the JDBC driver class that you want to use to cache data.

Note that you must also add the CacheDriver JAR file to the classpath.

The following examples show how to cache to several major databases. Refer to CacheConnection for more information on the JDBC URL syntax and typical connection properties.

Derby and Java DB

The driver simplifies Derby configuration. Java DB is the Oracle distribution of Derby. The JAR file is shipped in the JDK. You can find the JAR file, derby.jar, in the db subfolder of the JDK installation. In most caching scenarios, you need to specify only the following, after adding derby.jar to the classpath:

jdbc:anzo:CacheLocation='c:/Temp/cachedir';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;
To customize the Derby JDBC URL, use CacheDriver and CacheConnection. For example, to cache to an in-memory database, use a JDBC URL like the following:
jdbc:anzo:CacheDriver=org.apache.derby.jdbc.EmbeddedDriver;CacheConnection='jdbc:derby:memory';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;

SQLite

The following is a JDBC URL for the SQLite JDBC driver:

jdbc:anzo:CacheDriver=org.sqlite.JDBC;CacheConnection='jdbc:sqlite:C:/Temp/sqlite.db';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;

MySQL

The following is a JDBC URL for the included CData JDBC Driver for MySQL:

  jdbc:anzo:Cache Driver=cdata.jdbc.mysql.MySQLDriver;Cache Connection='jdbc:mysql:Server=localhost;Port=3306;Database=cache;User=root;Password=123456';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;
  

SQL Server

The following JDBC URL uses the Microsoft JDBC Driver for SQL Server:

jdbc:anzo:Cache Driver=com.microsoft.sqlserver.jdbc.SQLServerDriver;Cache Connection='jdbc:sqlserver://localhost\sqlexpress:7437;user=sa;password=123456;databaseName=Cache';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;

Oracle

The following is a JDBC URL for the Oracle Thin Client:

jdbc:anzo:Cache Driver=oracle.jdbc.OracleDriver;CacheConnection='jdbc:oracle:thin:scott/tiger@localhost:1521:orcldb';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;
NOTE: If using a version of Oracle older than 9i, the cache driver will instead be oracle.jdbc.driver.OracleDriver .

PostgreSQL

The following JDBC URL uses the official PostgreSQL JDBC driver:

jdbc:anzo:CacheDriver=cdata.jdbc.postgresql.PostgreSQLDriver;CacheConnection='jdbc:postgresql:User=postgres;Password=admin;Database=postgres;Server=localhost;Port=5432;';User=username;Password=password;url=http://35.184.41.230:8080/dataondemand/MyData;

CData JDBC Driver for Anzo

CacheConnection

The connection string for the cache database. This property is always used in conjunction with CacheProvider . Setting both properties will override the value set for CacheLocation for caching data.

Data Type

string

Default Value

""

Remarks

The cache database is determined based on the CacheDriver and CacheConnection properties. Both properties are required to use the cache database. Examples of common cache database settings can be found below. For more information on setting the caching database's driver, refer to CacheDriver.

The connection string specified in the CacheConnection property is passed directly to the underlying CacheDriver. Consult the documentation for the specific JDBC driver for more information on the available properties. Make sure to include the JDBC driver in your application's classpath.

Derby and Java DB

The driver simplifies caching to Derby, only requiring you to set the CacheLocation property to make a basic connection.

Alternatively, you can configure the connection to Derby manually using CacheDriver and CacheConnection. The following is the Derby JDBC URL syntax:

jdbc:derby:[subsubprotocol:][databaseName][;attribute=value[;attribute=value] ... ]
For example, to cache to an in-memory database, use the following:
jdbc:derby:memory

SQLite

To cache to SQLite, you can use the SQLite JDBC driver. The following is the syntax of the JDBC URL:

jdbc:sqlite:dataSource
  • Data Source: The path to an SQLite database file. Or, use a value of :memory to cache in memory.

MySQL

The installation includes the CData JDBC Driver for MySQL. The following is an example JDBC URL:

jdbc:mysql:User=root;Password=root;Server=localhost;Port=3306;Database=cache
The following are typical connection properties:

  • Server: The IP address or domain name of the server you want to connect to.
  • Port: The port that the server is running on.
  • User: The user name provided for authentication to the database.
  • Password: The password provided for authentication to the database.
  • Database: The name of the database.

SQL Server

The JDBC URL for the Microsoft JDBC Driver for SQL Server has the following syntax:

jdbc:sqlserver://[serverName[\instance][:port]][;database=databaseName][;property=value[;property=value] ... ]
For example:
jdbc:sqlserver://localhost\sqlexpress:1433;integratedSecurity=true
The following are typical SQL Server connection properties:
  • Server: The name or network address of the computer running SQL Server. To connect to a named instance instead of the default instance, this property can be used to specify the host name and the instance, separated by a backslash.
  • Port: The port SQL Server is running on.
  • Database: The name of the SQL Server database.
  • Integrated Security: Set this option to true to use the current Windows account for authentication. Set this option to false if you are setting the User and Password in the connection.

    To use integrated security, you will also need to add sqljdbc_auth.dll to a folder on the Windows system path. This file is located in the auth subfolder of the Microsoft JDBC Driver for SQL Server installation. The bitness of the assembly must match the bitness of your JVM.

  • User Id: The user name provided for authentication with SQL Server. This property is only needed if you are not using integrated security.
  • Password: The password provided for authentication with SQL Server. This property is only needed if you are not using integrated security.

Oracle

The following is the conventional JDBC URL syntax for the Oracle JDBC Thin driver:

jdbc:oracle:thin:[userId/password]@[//]host[[:port][:sid]]
For example:
jdbc:oracle:thin:scott/tiger@myhost:1521:orcl
The following are typical connection properties:
  • Data Source: The connect descriptor that identifies the Oracle database. This can be a TNS connect descriptor, an Oracle Net Services name that resolves to a connect descriptor, or, after version 11g, an Easy Connect naming (the host name of the Oracle server with an optional port and service name).

  • Password: The password provided for authentication with the Oracle database.
  • User Id: The user Id provided for authentication with the Oracle database.

PostgreSQL

The following is the JDBC URL syntax for the official PostgreSQL JDBC driver:

jdbc:postgresql:[//[host[:port]]/]database[[?option=value][[&option=value][&option=value] ... ]]
For example, the following connection string connects to a database on the default host (localhost) and port (5432):
jdbc:postgresql:postgres
The following are typical connection properties:
  • Host: The address of the server hosting the PostgreSQL database.
  • Port: The port used to connect to the server hosting the PostgreSQL database.
  • Database: The name of the database.
  • User name: The user Id provided for authentication with the PostgreSQL database. You can specify this in the JDBC URL with the "user" parameter.
  • Password: The password provided for authentication with the PostgreSQL database.

CData JDBC Driver for Anzo

CacheLocation

Specifies the path to the cache when caching to a file.

Data Type

string

Default Value

"%APPDATA%\\CData\\Anzo Data Provider"

Remarks

The CacheLocation is a simple, file-based cache. The driver uses Java DB, Oracle's distribution of the Derby database. To cache to Java DB, you will need to add the Java DB JAR file to the classpath. The JAR file, derby.jar, is shipped in the JDK and located in the db subfolder of the JDK installation.

If left unspecified, the default location is "%APPDATA%\\CData\\Anzo Data Provider" with %APPDATA% being set to the user's configuration directory:

Platform %APPDATA%
Windows The value of the APPDATA environment variable
Mac ~/Library/Application Support
Linux ~/.config

See Also

  • AutoCache: Set to implicitly create and maintain a cache for later offline use.
  • CacheMetadata: Set to persist the Anzo catalog in CacheLocation.

CData JDBC Driver for Anzo

CacheTolerance

The tolerance for stale data in the cache specified in seconds when using AutoCache .

Data Type

int

Default Value

600

Remarks

The tolerance for stale data in the cache specified in seconds. This only applies when AutoCache is used. The driver checks with the data source for newer records after the tolerance interval has expired. Otherwise, it returns the data directly from the cache.

CData JDBC Driver for Anzo

Offline

Use offline mode to get the data from the cache instead of the live source.

Data Type

bool

Default Value

false

Remarks

When Offline = true, all queries execute against the cache as opposed to the live data source. In this mode, certain queries like INSERT, UPDATE, DELETE, and CACHE are not allowed.

CData JDBC Driver for Anzo

CacheMetadata

This property determines whether or not to cache the table metadata to a file store.

Data Type

bool

Default Value

false

Remarks

As you execute queries with this property set, table metadata in the Anzo catalog are cached to the file store specified by CacheLocation if set or the user's home directory otherwise. A table's metadata will be retrieved only once, when the table is queried for the first time.

When to Use CacheMetadata

The driver automatically persists metadata in memory for up to two hours when you first discover the metadata for a table or view and therefore, CacheMetadata is generally not required. CacheMetadata becomes useful when metadata operations are expensive such as when you are working with large amounts of metadata or when you have many short-lived connections.

When Not to Use CacheMetadata

  • When you are working with volatile metadata: Metadata for a table is only retrieved the first time the connection to the table is made. To pick up new, changed, or deleted columns, you would need to delete and rebuild the metadata cache. Therefore, it is best to rely on the in-memory caching for cases where metadata changes often.
  • When you are caching to a database: CacheMetadata can only be used with CacheLocation. If you are caching to another database with the CacheDriver and CacheConnection properties, use AutoCache to cache implicitly. Or, use CACHE Statements to cache explicitly.

CData JDBC Driver for Anzo

Miscellaneous

This section provides a complete list of the Miscellaneous properties you can configure in the connection string for this provider.


PropertyDescription
BatchSizeThe maximum size of each batch operation to submit.
ConnectionLifeTimeThe maximum lifetime of a connection in seconds. Once the time has elapsed, the connection object is disposed.
ConnectOnOpenThis property specifies whether to connect to the Anzo when the connection is opened.
CustomHeadersOther headers as determined by the user (optional).
CustomUrlParamsThe custom query string to be included in the request.
MaxRowsLimits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.
OtherThese hidden properties are used only in specific use cases.
PagesizeThe maximum number of results to return per page from Anzo.
PoolIdleTimeoutThe allowed idle time for a connection before it is closed.
PoolMaxSizeThe maximum connections in the pool.
PoolMinSizeThe minimum number of connections in the pool.
PoolWaitTimeThe max seconds to wait for an available connection.
PseudoColumnsThis property indicates whether or not to include pseudo columns as columns to the table.
SupportEnhancedSQLThis property enhances SQL functionality beyond what can be supported through the API directly, by enabling in-memory client-side processing.
TimeoutThe value in seconds until the timeout error is thrown, canceling the operation.
UseConnectionPoolingThis property enables connection pooling.
CData JDBC Driver for Anzo

BatchSize

The maximum size of each batch operation to submit.

Data Type

int

Default Value

0

Remarks

When BatchSize is set to a value greater than 0, the batch operation will split the entire batch into separate batches of size BatchSize. The split batches will then be submitted to the server individually. This is useful when the server has limitations on the size of the request that can be submitted.

Setting BatchSize to 0 will submit the entire batch as specified.

CData JDBC Driver for Anzo

ConnectionLifeTime

The maximum lifetime of a connection in seconds. Once the time has elapsed, the connection object is disposed.

Data Type

int

Default Value

0

Remarks

The maximum lifetime of a connection in seconds. Once the time has elapsed, the connection object is disposed. The default is 0 which indicates there is no limit to the connection lifetime.

CData JDBC Driver for Anzo

ConnectOnOpen

This property specifies whether to connect to the Anzo when the connection is opened.

Data Type

bool

Default Value

false

Remarks

When set to true, a connection will be made to Anzo when the connection is opened. This property enables the Test Connection feature available in various database tools.

This feature acts as a NOOP command as it is used to verify a connection can be made to Anzo and nothing from this initial connection is maintained.

Setting this property to false may provide performance improvements (depending upon the number of times a connection is opened).

CData JDBC Driver for Anzo

CustomHeaders

Other headers as determined by the user (optional).

Data Type

string

Default Value

""

Remarks

This property can be set to a string of headers to be appended to the HTTP request headers created from other properties, like ContentType, From, and so on.

The headers must be of the format "header: value" as described in the HTTP specifications. Header lines should be separated by the carriage return and line feed (CRLF) characters.

Use this property with caution. If this property contains invalid headers, HTTP requests may fail.

This property is useful for fine-tuning the functionality of the driver to integrate with specialized or nonstandard APIs.

CData JDBC Driver for Anzo

CustomUrlParams

The custom query string to be included in the request.

Data Type

string

Default Value

""

Remarks

The CustomUrlParams allow you to specify custom query string parameters that are included with the HTTP request. The parameters must be encoded as a query string in the form field1=value1&field2=value2&field3=value3. The values in the query string must be URL encoded.

CData JDBC Driver for Anzo

MaxRows

Limits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.

Data Type

int

Default Value

-1

Remarks

Limits the number of rows returned rows when no aggregation or group by is used in the query. This helps avoid performance issues at design time.

CData JDBC Driver for Anzo

Other

These hidden properties are used only in specific use cases.

Data Type

string

Default Value

""

Remarks

The properties listed below are available for specific use cases. Normal driver use cases and functionality should not require these properties.

Specify multiple properties in a semicolon-separated list.

Caching Configuration

CachePartial=TrueCaches only a subset of columns, which you can specify in your query.
QueryPassthrough=TruePasses the specified query to the cache database instead of using the SQL parser of the driver.

Integration and Formatting

DefaultColumnSizeSets the default length of string fields when the data source does not provide column length in the metadata. The default value is 2000.
ConvertDateTimeToGMTDetermines whether to convert date-time values to GMT, instead of the local time of the machine.
RecordToFile=filenameRecords the underlying socket data transfer to the specified file.

CData JDBC Driver for Anzo

Pagesize

The maximum number of results to return per page from Anzo.

Data Type

int

Default Value

5000

Remarks

The Pagesize property affects the maximum number of results to return per page from Anzo. Setting a higher value may result in better performance at the cost of additional memory allocated per page consumed.

CData JDBC Driver for Anzo

PoolIdleTimeout

The allowed idle time for a connection before it is closed.

Data Type

int

Default Value

60

Remarks

The allowed idle time a connection can remain in the pool until the connection is closed. The default is 60 seconds.

CData JDBC Driver for Anzo

PoolMaxSize

The maximum connections in the pool.

Data Type

int

Default Value

100

Remarks

The maximum connections in the pool. The default is 100. To disable this property, set the property value to 0 or less.

CData JDBC Driver for Anzo

PoolMinSize

The minimum number of connections in the pool.

Data Type

int

Default Value

1

Remarks

The minimum number of connections in the pool. The default is 1.

CData JDBC Driver for Anzo

PoolWaitTime

The max seconds to wait for an available connection.

Data Type

int

Default Value

60

Remarks

The max seconds to wait for a connection to become available. If a new connection request is waiting for an available connection and exceeds this time, an error is thrown. By default, new requests wait forever for an available connection.

CData JDBC Driver for Anzo

PseudoColumns

This property indicates whether or not to include pseudo columns as columns to the table.

Data Type

string

Default Value

""

Remarks

This setting is particularly helpful in Entity Framework, which does not allow you to set a value for a pseudo column unless it is a table column. The value of this connection setting is of the format "Table1=Column1, Table1=Column2, Table2=Column3". You can use the "*" character to include all tables and all columns; for example, "*=*".

CData JDBC Driver for Anzo

SupportEnhancedSQL

This property enhances SQL functionality beyond what can be supported through the API directly, by enabling in-memory client-side processing.

Data Type

bool

Default Value

true

Remarks

When SupportEnhancedSQL = true, the driver offloads as much of the SELECT statement processing as possible to Anzo and then processes the rest of the query in memory. In this way, the driver can execute unsupported predicates, joins, and aggregation.

When SupportEnhancedSQL = false, the driver limits SQL execution to what is supported by the Anzo API.

Execution of Predicates

The driver determines which of the clauses are supported by the data source and then pushes them to the source to get the smallest superset of rows that would satisfy the query. It then filters the rest of the rows locally. The filter operation is streamed, which enables the driver to filter effectively for even very large datasets.

Execution of Joins

The driver uses various techniques to join in memory. The driver trades off memory utilization against the requirement of reading the same table more than once.

Execution of Aggregates

The driver retrieves all rows necessary to process the aggregation in memory.

CData JDBC Driver for Anzo

Timeout

The value in seconds until the timeout error is thrown, canceling the operation.

Data Type

int

Default Value

300

Remarks

If Timeout = 0, operations do not time out. The operations run until they complete successfully or until they encounter an error condition.

If Timeout expires and the operation is not yet complete, the driver throws an exception.

CData JDBC Driver for Anzo

UseConnectionPooling

This property enables connection pooling.

Data Type

bool

Default Value

false

Remarks

This property enables connection pooling. The default is false. See Connection Pooling for information on using connection pools.

Copyright (c) 2022 CData Software, Inc. - All rights reserved.
Build 21.0.8171