Create a Data Access Object for Zoho Creator Data using JDBI

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Zoho Creator JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Zoho Creator.

A brief overview of creating a SQL Object API for Zoho Creator data in JDBI.

JDBI is a SQL convenience library for Java that exposes two different style APIs, a fluent style and a SQL object style. The CData JDBC Driver for Zoho Creator integrates connectivity to live Zoho Creator data in Java applications. By pairing these technologies, you gain simple, programmatic access to Zoho Creator data. This article walks through building a basic Data Access Object (DAO) and the accompanying code to read and write Zoho Creator data.

Create a DAO for the Zoho Creator Leave_Types Entity

The interface below declares the desired behavior for the SQL object to create a single method for each SQL statement to be implemented.

public interface MyLeave_TypesDAO { //insert new data into Zoho Creator @SqlUpdate("INSERT INTO Leave_Types (Leave_Type, Leave_Type) values (:leave_Type, :leave_Type)") void insert(@Bind("leave_Type") String leave_Type, @Bind("leave_Type") String leave_Type); //request specific data from Zoho Creator (String type is used for simplicity) @SqlQuery("SELECT Leave_Type FROM Leave_Types WHERE Leave_Type = :leave_Type") String findLeave_TypeByLeave_Type(@Bind("leave_Type") String leave_Type); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Zoho Creator

Collect the necessary connection properties and construct the appropriate JDBC URL for connecting to Zoho Creator.

The connector is already registered with Zoho Creator as an OAuth application.

If you would prefer to use your own custom OAuth app, see the Help documentation.

Built-in Connection String Designer

For assistance in constructing the JDBC URL, use the connection string designer built into the Zoho Creator JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

java -jar cdata.jdbc.zohocreator.jar

Fill in the connection properties and copy the connection string to the clipboard.

A connection string for Zoho Creator will typically look like the following:


Use the configured JDBC URL to obtain an instance of the DAO interface. The particular method shown below will open a handle bound to the instance, so the instance needs to be closed explicitly to release the handle and the bound JDBC connection.

DBI dbi = new DBI("jdbc:zohocreator:AccountsServer=AccountsServer;InitiateOAuth=GETANDREFRESH"); MyLeave_TypesDAO dao =; //do stuff with the DAO dao.close();

Read Zoho Creator Data

With the connection open to Zoho Creator, simply call the previously defined method to retrieve data from the Leave_Types entity in Zoho Creator.

//disply the result of our 'find' method String leave_Type = dao.findLeave_TypeByLeave_Type("Sick"); System.out.println(leave_Type);

Write Zoho Creator Data

It is also simple to write data to Zoho Creator, using the previously defined method.

//add a new entry to the Leave_Types entity dao.insert(newLeave_Type, newLeave_Type);

Since the JDBI library is able to work with JDBC connections, you can easily produce a SQL Object API for Zoho Creator by integrating with the CData JDBC Driver for Zoho Creator. Download a free trial and work with live Zoho Creator data in custom Java applications today.