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 REST 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:
cdata.jdbc.rest.RESTDriver
- Provide the JDBC URL. For example:
jdbc:rest:DataModel=Relational;URI=C:\people.xml;Format=XML or jdbc:cdata:rest:DataModel=Relational;URI=C:\people.xml;Format=XML
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:rest:" or "jdbc:cdata:rest:" and can include any of the connection properties in name-value pairs separated with semicolons.
Modeling XML/JSON/CSV Data
The DataModel property controls how your data is represented into tables.
- Document (default): Model a top-level, document view of your REST data. The driver returns nested object arrays as aggregated XML/JSON/CSV objects.
- FlattenedDocuments: Implicitly join nested array objects and parent objects into a single table.
- Relational: View nested object arrays as individual, related tables containing a primary key and a foreign key that links to the parent document.
Set Format to XML, JSON, or CSV in accordance with the data structuring standard used by the REST source you want to connect to. and set DataModel to more closely match the data representation to the structure of your data.
Next Steps
- See Modeling REST Data for information on customizing schema discovery and executing SQL to REST.
- See Fine-Tuning Data Access for more advanced connection settings: fine-tune the default data modeling settings, connect through a firewall, or troubleshoot connections.