Ready to get started?

Download a free trial of the Zoho Projects Driver to get started:

 Download Now

Learn more:

Zoho Projects Icon Zoho Projects JDBC Driver

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

Create a Data Access Object for Zoho Projects Data using JDBI



A brief overview of creating a SQL Object API for Zoho Projects 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 Projects integrates connectivity to live Zoho Projects data in Java applications. By pairing these technologies, you gain simple, programmatic access to Zoho Projects data. This article walks through building a basic Data Access Object (DAO) and the accompanying code to read and write Zoho Projects data.

Create a DAO for the Zoho Projects Portals 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 MyPortalsDAO { //insert new data into Zoho Projects @SqlUpdate("INSERT INTO Portals (CrmPartner, Name) values (:crmPartner, :name)") void insert(@Bind("crmPartner") String crmPartner, @Bind("name") String name); //request specific data from Zoho Projects (String type is used for simplicity) @SqlQuery("SELECT Name FROM Portals WHERE CrmPartner = :crmPartner") String findNameByCrmPartner(@Bind("crmPartner") String crmPartner); /* * close with no args is used to close the connection */ void close(); }

Open a Connection to Zoho Projects

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

The connector uses OAuth to authenticate with Zoho Projects. CData Software has already registered an OAuth application with Zoho Project which is embedded and used to authenticate.

If you use the embedded credentials, set the InitiateOAuth connection property to "GETANDREFRESH".

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 Projects JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

java -jar cdata.jdbc.zohoprojects.jar

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

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

jdbc:zohoprojects:InitiateOAuth=GETANDREFRESH

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:zohoprojects:InitiateOAuth=GETANDREFRESH"); MyPortalsDAO dao = dbi.open(MyPortalsDAO.class); //do stuff with the DAO dao.close();

Read Zoho Projects Data

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

//disply the result of our 'find' method String name = dao.findNameByCrmPartner("true"); System.out.println(name);

Write Zoho Projects Data

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

//add a new entry to the Portals entity dao.insert(newCrmPartner, newName);

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