Developer Guide: AI-Assisted Java Development with the CData CLI

Build Java applications faster with AI-assisted development. This guide walks you through using the CData CLI with an AI coding tool like Cursor to generate production-ready Java code that connects to live data using CData JDBC Drivers.

The CData CLI gives your AI coding assistant a schema-aware command-line interface to your actual data source. Instead of guessing table and column names, the assistant runs cdatacli commands to discover the real schema and validate SQL before it writes a line of code. The result is accurate Java that you can run in production using CData JDBC Drivers - no hallucinated field names. And because the CLI is built on the same JDBC driver, the JAR it downloads is the very one your application uses at runtime.

By the end of this guide, you'll have a working Java console application that:

  • Connects to Google Sheets using the CData JDBC Driver
  • Queries customer data using standard JDBC patterns
  • Displays results in a formatted table

Architecture overview

The CData CLI bridges AI-assisted development with production-ready data access:

┌───────────────────┐     ┌───────────────────┐     ┌───────────────────┐
│  AI Coding Tool   │     │     CData CLI     │     │   Google Sheets   │
│   (Cursor, etc.)  │────>│  (schema + SQL)   │────>│    (live data)    │
│                   │<────│                   │<────│                   │
└───────────────────┘     └───────────────────┘     └───────────────────┘
          │
          │  generates Java code
          v
┌───────────────────┐     ┌───────────────────┐     ┌───────────────────┐
│   Your Java App   │     │    CData JDBC     │     │   Google Sheets   │
│                   │────>│      Driver       │────>│    (live data)    │
│   (production)    │<────│                   │<────│                   │
└───────────────────┘     └───────────────────┘     └───────────────────┘

How it works:

  1. The CData CLI connects to your data source and exposes schema and query commands to your AI assistant
  2. The assistant runs those commands to discover the real schema and generate accurate Java with correct table and column names
  3. Your production application uses the CData JDBC Driver - same schema, same SQL syntax, same JAR the CLI downloaded

Prerequisites

Before you begin, ensure the following are installed:

You don't need a separate JDBC Driver download - the CLI fetches it in Step 3, and the same JAR runs your application.


Step 1: Set up sample data in Google Sheets

We'll use a sample Google Sheet containing sample CRM data to demonstrate the workflow.

  1. Navigate to the sample CRM spreadsheet
  2. Click File > Make a copy to save it to your Google Drive
  3. Give it a memorable name (e.g., "demo_organization") - you'll need this later

The spreadsheet contains four sheets:

  • account - Company information (Name, Industry, AnnualRevenue, NumberOfEmployees)
  • opportunity - Sales pipeline data (StageName, Amount, Probability, CloseDate)
  • tickets - Support cases (Subject, Priority, Status, CreatedAt)
  • usage - Product usage statistics (PRODUCT_GROUP, S_STANDARDJOBRUNS, S_RECORDSAFFECTED)

The CData CLI exposes each sheet as a table named _. So the account sheet in your demo_organization copy is the table demo_organization_account. You don't have to memorize this - the CLI reports the exact names in Step 5.

Step 2: Install the CData CLI

The CData CLI is a single command-line tool, cdatacli, that manages CData drivers, saved connections, and queries. Run the one-line installer for your OS:

  1. macOS: curl -fsSL https://downloads.cdata.com/cdatabuilds/builds/free/cdatacli/install-cdatacli-macos.sh | bash
  2. Linux: curl -fsSL https://downloads.cdata.com/cdatabuilds/builds/free/cdatacli/install-cdatacli-linux.sh | bash
  3. Windows (PowerShell): irm https://downloads.cdata.com/cdatabuilds/builds/free/cdatacli/install-cdatacli-windows.ps1 | iex
  4. Confirm the CLI is working: cdatacli --version

The CLI runs on Java 17 or later. If you see a message that Java is required, install a JDK (see Prerequisites) and make sure java is on your PATH.

Step 3: Download and license the Google Sheets driver

The CLI can find and download CData drivers for you - no separate installer required. The JAR it downloads is the same one you'll put on your application's classpath.

  1. Search the driver catalog to find the Google Sheets driver: cdatacli drivers search --driver "sheets"

    Note the artifactId in the output - googlesheets-jdbc.

    {
      "drivers" : [ {
        "groupId" : "cdata",
        "artifactId" : "googlesheets-jdbc",
        "name" : "CData JDBC Driver For Google Sheets 2025",
        "version" : "25.0.9539",
        "url" : "https://maven.cdata.com/p/jdbc/cdata/googlesheets-jdbc/25.0.9539/googlesheets-jdbc-25.0.9539.jar"
      } ]
    }
  2. Download the driver (note the output path - you'll reference this JAR on your classpath later): cdatacli drivers download --artifact-id googlesheets-jdbc
  3. Activate a license. Use your license key, or TRIAL for a 30-day evaluation: cdatacli drivers activate "Google Sheets" --name "Jane Smith" --email "[email protected]" --trial
  4. Confirm the driver is installed and activated: cdatacli drivers list
    {
      "drivers" : [ {
        "name" : "Google Sheets",
        "product" : "CData JDBC Driver For Google Sheets 2025",
        "version" : "25.0.9539.0",
        "activated" : true
      } ]
    }

Step 4: Create a saved connection

A saved connection stores your data source settings so the CLI - and your AI assistant - can reuse them. Google Sheets uses OAuth, so creating the connection launches a browser for you to authorize access. The CLI then stores the resulting token and reuses it automatically; you only sign in once.

  1. Create the connection. The GETANDREFRESH setting tells the driver to open your browser and obtain a token: cdatacli connection create --name gsheets --driver "Google Sheets" --connectionstring "Spreadsheet=demo_organization;InitiateOAuth=GETANDREFRESH"
  2. Your browser opens to Google's consent screen. Click Continue to grant access. The command finishes once you've authorized. Google OAuth consent screen for the CData connection CData callback page reading Google Authorization Successful
  3. Verify the connection was saved (secrets are stored encrypted, never in plain text): cdatacli connection list

Step 5: Give your AI assistant the CLI skill

The CLI ships per-driver guidance that teaches your AI assistant how to discover schema and run SQL through cdatacli. Saving this guidance as a project rule means the assistant always has accurate context.

  1. Generate the skill guidance for Google Sheets and save it as a Cursor project rule: cdatacli drivers skill "Google Sheets" > .cursor/rules/cdata-googlesheets.md

    The output is a Markdown skill that tells the assistant which cdatacli commands to run for schema discovery and query validation against your gsheets connection.

  2. Confirm the assistant can see the schema by running a metadata command yourself: cdatacli metadata columns --connection gsheets --table "demo_organization_account"

    This lists the real columns - Name, Industry, AnnualRevenue, and more - exactly as your assistant will discover them.

    {
      "columns" : [
        { "COLUMN_NAME" : "Name",          "TYPE_NAME" : "VARCHAR" },
        { "COLUMN_NAME" : "Industry",      "TYPE_NAME" : "VARCHAR" },
        { "COLUMN_NAME" : "AnnualRevenue", "TYPE_NAME" : "BIGINT" }
      ]
    }

Step 6: Build and run the application with Cursor

  1. Create a new folder for your project and open it in Cursor (keep the .cursor/rules/cdata-googlesheets.md rule from Step 5 in the project)
  2. Open Cursor's AI chat pane and prompt it to build the application. Because the CLI skill is in your project rules, the assistant will run cdatacli to confirm the schema first:
    Build a Java console application that connects to Google Sheets using the CData JDBC Driver. Use the CData CLI to discover the schema of my gsheets connection, then query the account sheet and display all accounts with their Name, Industry, and AnnualRevenue in a formatted table. Store the connection string in an environment variable for security.
  3. Cursor generates Java that uses proper JDBC patterns and correct table and column names (verified against the live schema), reading the connection string from an environment variable.
  4. Set the connection string, then compile and run with the downloaded JAR on your classpath. Use the path reported by cdatacli drivers download in Step 3:
    export GOOGLESHEETS_CONN="jdbc:googlesheets:Spreadsheet=demo_organization;InitiateOAuth=GETANDREFRESH;"
    javac -cp ".:/path/to/cdata.jdbc.googlesheets.jar" GoogleSheetsApp.java
    java -cp ".:/path/to/cdata.jdbc.googlesheets.jar" GoogleSheetsApp

    On Windows, use set instead of export and ; instead of : as the classpath separator.

Example output

Name                        Industry            AnnualRevenue
------------------------------------------------------------
Acme Corporation            Technology          2500000
Global Industries           Manufacturing       15000000
StartupCo                   Software            500000
Enterprise Inc              Finance             50000000

What's next?

You've built a working Java application using AI-assisted development. The same pattern works for any of the hundreds of data sources supported by CData JDBC Drivers.

Try these next steps:

  • Add CRUD operations (Create, Update, Delete) to your application
  • Query multiple sheets and join data
  • Build a Spring Boot REST API with live data
  • Connect to a different data source like Salesforce or Jira - just download that driver with the CLI and repeat

Troubleshooting

If you encounter issues, try these common solutions:

  • "Java is required" when running cdatacli - Install a Java 17+ JDK (see Prerequisites) and confirm java -version works in the same terminal.
  • OAuth authentication fails or the browser doesn't open - Ensure pop-ups are enabled and that you can reach a browser from the machine running the CLI. Re-run cdatacli connection create to retry the consent flow.
  • ClassNotFoundException for the JDBC Driver - Verify the downloaded JAR is on your classpath. Use the exact path reported by cdatacli drivers download.
  • "Could not find a valid license" - Activate the driver with cdatacli drivers activate. The license applies to the same JAR your application runs.
  • AI generates incorrect column names - Confirm the .cursor/rules/cdata-googlesheets.md rule is present, and ask the assistant to re-run cdatacli metadata columns before generating code.

JDBC development with CData

The CData CLI and CData JDBC Drivers share the same data model - in fact, the same JAR - so the SQL your assistant validates during development works identically in production. This eliminates the disconnect between AI-generated code and real-world data access.

The CLI is model agnostic - it works with any AI model your coding tool supports. Whether you're using GPT-4, Claude, or another model in Cursor, the assistant gets the same accurate schema by running the same commands.

Ready to accelerate your Java development? Download the CData CLI and get a free trial of the CData JDBC Driver for Google Sheets to get started.