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 Airtable 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.airtable.AirtableDriver
- Provide the JDBC URL. For example:
jdbc:airtable:APIKey=keymz3adb53RqsU;BaseId=appxxN2fe34r3rjdG7;TableNames=TableA,TableB,TableC;ViewNames=TableA.ViewA,TableA.ViewB,..,TableX.ViewY; or jdbc:cdata:airtable:APIKey=keymz3adb53RqsU;BaseId=appxxN2fe34r3rjdG7;TableNames=TableA,TableB,TableC;ViewNames=TableA.ViewA,TableA.ViewB,..,TableX.ViewY;
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:airtable:" or "jdbc:cdata:airtable:" and can include any of the connection properties in name-value pairs separated with semicolons.
Connecting to Airtable
The driver requests tables and views from Airtable. Authenticate, specify a base, and specify a list of tables to connect.
- ApiKey: Log into Airtable and navigate to the Account icon in the top-right corner. Then, select Account from the dropdown menu. From the Account page, navigate to the API section. Then, click Generate API key. Set the ApiKey to the generated key.
- BaseId: From the same API section, identify your BaseId. To locate this value, navigate to https://airtable.com/api and select a base. In the introduction section of the Airtable documentation for the selected base, note the value specified in "The ID of this base is Id."
- TableNames: A comma-separated list of table names for the selected base in the format TableA,TableB..etc.. Supply the table names exactly as they are displayed in the Airtable UI.
- ViewNames (optional): A comma-separated list of views in the format TableA.ViewA,TableA.ViewB,..etc. These are the same names of the views as found in the UI.
Note: Do not use the '.' character in column names. It is used for building column names based on paths and may risk breaking INSERT/UPDATE statements. If you already have column names that contain the '.' character, set PathDelimiter to a character that is not used in column names.