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 OData 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. Note that the .lic file must be located in the same folder as the JAR file.
- Provide the driver class. For example:
- Provide the JDBC URL. For example:
jdbc:odata:User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot; or jdbc:cdata:odata:User=myuseraccount;Password=mypassword;URL=http://myserver/myOrgRoot;
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:odata:" or "jdbc:cdata:odata:" and can include any of the connection properties in name-value pairs separated with semicolons.
Connecting to OData
To connect, you need to set the Url to a valid OData service root URI in addition to the authentication values.
Also, you can specify a CacheLocation to store the metadata of your OData organization. This keeps the CData JDBC Driver for OData from having to send requests for metadata on each connection.
Authenticating to OData
The driver supports the major authentication schemes, including HTTP and Windows.
Set AuthScheme to use the following authentication types.
- HTTP Authentication: The driver supports authentication with HTTP Basic, Digest, and custom headers. To use Basic or Digest, set the User and Password. You can specify other authentication values in CustomHeaders.
- Windows (NTLM): Set the Windows User and Password to connect and set AuthScheme to "NTLM".
- Kerberos and Kerberos Delegation: To authenticate with Kerberos, set AuthScheme to NEGOTIATE. To use Kerberos Delegation, set AuthScheme to KERBEROSDELEGATION. If needed, provide the User, Password, and KerberosSPN. By default, the driver attempts to communicate with the SPN at the specified Url.
Securing OData Connections
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.