September 30, 2012
Integrate Web Services with c-treeACE SQL
Note: c-treeACE became FairCom DB in October 2020.
Many developers have expressed an interest in adding Web Services to their existing applications. A Web Service allows them to expand the power of their c‑treeACE SQL database making it available to other applications. We have produced a tutorial to demonstrate how to create a Web Service implementing FairCom’s standard JDBC layer. In this tutorial, you will learn how to create a Web Service that makes a c‑treeACE SQL database (a sample customer list called custmast) available to JEE (Java Enterprise Edition) applications. JEE allows developers to combine modules built with EJB (Enterprise Java Beans) to create powerful enterprise applications.
You can use these principles to make your own database available as a Web Service to JEE applications of your choosing. Typical operations you may want a Web Service to perform might include the ability to add, edit, or delete records. You could perform complex queries specific to your application. Or you might invoke stored procedures containing your business logic.
For this tutorial, it’s best to have a working knowledge of Web Services and the c‑treeACE SQL JDBC driver. And, of course, you will need to have NetBeans and GlassFish installed and ready to go, as well as a Java Developer Kit (JDK) and the Java Runtime Environment (JRE).
This example will use the c‑treeACE sample custmast database. If you have run any of the standard c‑treeACE tutorials, you will have a custmast database and it will contain a few records. If you do not have a custmast database, you will need to create one. Either run one of the c‑treeACE tutorials or use the c‑treeACE SQL Explorer tool to create one.
In this tutorial you will:
- Configure GlassFish
- Create a Project in NetBeans
- Set Up the DataSource in GlassFish using c‑treeACE SQL JDBC.
- Create the Web Service:
- Create an “empty” Web Service, which will be a file called custmast.java.
- Create the two operations: SearchByCustNum and SelectAll.
- Build and deploy the Web Service.
- Create the Servlet to connect the web page to the Web Service. The Servlet will call the appropriate operation in the Web Service (either SearchByCustNum or SelectAll).
- Edit the initial web page, index.jsp, to create two Submit buttons labeled Read Customer: one will call SearchByCustNum; the other will call SelectAll.
- Try it out. An example of SelectAll is shown in the browser earlier in this article.
The tutorial—including complete step-by-step instructions and all the necessary source code—is available from FairCom: Web Service Tutorial PDF
Stay tuned for more exciting tips and tricks from FairCom.