Professional Documents
Culture Documents
OData JavaConsumer Jun2013
OData JavaConsumer Jun2013
OData JavaConsumer Jun2013
Odata4j
Odata4j is an open source toolkit that provides both OData producer and consumer frameworks
for Java applications. Information on this toolkit can be found at their Web site
(http://code.google.com/p/odata4j/).
This toolkit is the basis for the Java OData consumer discussed in this article. I created a
sample console application that shows data retrieval.
2013 Actian Corporation. All rights reserved. Printed in the U.S.A. Actian is a trademark of Actian Corporation in the United States
and in other countries. All other trademarks, trade names, service marks, and logos referenced herein belong to their respective
companies.
Note that a complete OData solution for Java requires both a producer and a consumer. I have
also implemented a basic Java provider that you can configure to share your database. Refer
to Creating an OData Java Producer for Actian PSQL for details on the producer portion.
One system installed with PSQL Vx Server 11 SP3. This system also needs to have the
Java Runtime Environment (JRE) installed. You can either use the JRE installed by
PSQL or install a different version. This is the system on which the OData producer
runs.
A development system with Eclipse and the Java Development Kit (JDK) installed. I
used JDK 1.6.0_31. I ran the consumer application on this system as well, but you may
run it from a third system that has the JRE installed.
This application only queries data. It does not insert, update, or delete data. The entity
data model in which the OData protocol is built upon requires primary keys to be defined
on tables to perform insert, update, and delete operations. DEMODATA does not have
any primary keys defined. To see examples of insert, update, and delete operations,
review the ODataTestServiceReadWriteExample.java file. That file is contained in the
source archive for the odata4j v0.7 download from the odata4j Web site. See
http://code.google.com/p/odata4j/downloads/list.
The companion Java producer is intended to show that an OData producer can expose
information from PSQL using JDBC. The producer is not very robust and may not be
completely compliant with the OData specification. However, the odata4j group is
currently working on a JDBC producer to be included natively in their package. Once
that producer is available, the companion producer that I created will be obsolete.
2013 Actian Corporation. All rights reserved. Printed in the U.S.A. Actian is a trademark of Actian Corporation in the United States
and in other countries. All other trademarks, trade names, service marks, and logos referenced herein belong to their respective
companies.