The CData JDBC Driver for REST enables the granular control useful in more complex deployments or network topologies; you can use the following connection properties to fine-tune data access, connect through a firewall, or troubleshoot connections.
Configuring Automatic Schema Discovery
By default, the driver models REST data as tables through Automatic Schema Discovery. The available connection properties give you high-level control over the detected schemas. The following sections outline the driver's defaults and link to ways to further customize.
- FlattenArrays: Set this property to the number of the elements in a primitive array that you want to return as column values. You can also use this property with FlattenObjects to extract the properties of objects nested in arrays -- arrays are returned as aggregates by default.
FlattenObjects: By default, this is true; that is, the properties of objects and nested objects are returned as columns. When you set FlattenArrays, objects nested in the specified array elements are also flattened and returned as columns.
Other mechanisms for accessing nested objects are detailed in Modeling REST Data.
Flattening Nested XML
By default, the driver projects columns over the properties of objects. Arrays are returned as XML aggregates, by default.
- Object: Any parent element that does not repeat at the same height.
- Array: Any element that repeats at the same height.
In the following example, jobs is a primitive array:
In the following example, maintenance is an object array, since each maintenance node has child elements.
<maintenance> <date>07-17-2017</date> <desc>oil change</desc> </maintenance> <maintenance> <date>01-03-2018</date> <desc>new tires</desc> </maintenance>
Fine-Tuning Data Access
You can use the following properties to gain greater control over how the driver parses the XML data into rows. You can also customize the schemas detected based on the connection string.
- RowScanDepth: This property determines the number of rows that will be scanned to detect column data types when generating table metadata.
- XPath: Explicitly specify the paths to nested object arrays, instead of detecting them during the row scan.
GenerateSchemaFiles: This property enables you to persist table metadata in static schema files that are easy to customize, to persist your changes to column data types, for example. Set this property to "OnStart" to generate schema files for all tables in your database at connection. Or, set this property to "OnUse" to generate schemas as you execute SELECT queries to tables. The resulting schemas are based on the connection properties you use to configure Automatic Schema Discovery.
To use the resulting schema files, set the Location property to the folder containing the schemas. See Customizing Schemas for more information.
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.
Connecting Through a Firewall or Proxy
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.
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.
Troubleshooting the Connection
To show driver activity from query execution to network traffic, use Logfile and Verbosity. The examples of common connection errors below show how to use these properties to get more context. Contact the support team for help tracing the source of an error or circumventing a performance issue.
- Authentication errors: Typically, recording a Logfile at Verbosity 4 is necessary to get full details on an authentication error.
- Queries time out: A server that takes too long to respond will exceed the driver's client-side timeout. Often, setting the Timeout property to a higher value will avoid a connection error. Another option is to disable the timeout by setting the property to 0. Setting Verbosity to 2 will show where the time is being spent.
- The certificate presented by the server cannot be validated: This error indicates that the driver cannot validate the server's certificate through the chain of trust. If you are using a self-signed certificate, there is only one certificate in the chain.
To resolve this error, you must verify yourself that the certificate can be trusted and specify to the driver that you trust the certificate. One way you can specify that you trust a certificate is to add the certificate to the trusted system store; another is to set SSLServerCert.