Date Posted: April 3, 2007
What is IBM Database Connectivity for JavaScript?
IBM® Database Connectivity for JavaScript™ is middleware that enables Web clients to directly access server-side relational data without compromising enterprise security. On the client, IBM Database Connectivity for JavaScript consists of a JavaScript API and library that can be used by Web applications without special browser plug-ins. On the server, the IBM Database Connectivity for JavaScript gateway, written in PHP, is an adaptor layer that mediates between IBM Database Connectivity for JavaScript and relational databases and provides functions such as operation forwarding and security. Web 2.0 applications can thus use IBM Database Connectivity for JavaScript to access relational data as a first-class construct instead of through ad hoc protocols.
IBM Database Connectivity for JavaScript supports the trend for Web applications to be dynamically composed in a Web browser -- so-called "Web 2.0" applications -- instead of being completely composed on the server ("Web 1.0"). IBM Database Connectivity for JavaScript is specifically geared toward enabling the potential Web 2.0 benefits of increased application responsiveness and the ability to flexibly combine information from various sources on the client. Web 2.0 access to server-side data, however, is currently characterized by Representational State Transfer (REST)-like APIs, which are typically application specific. For many applications, a more general-purpose data-access API would be more appropriate. ODBC (Open Database Connectivity), for example, along with its various language-dependent incarnations, such as JDBC (Java Database Connectivity) for Java or PDO (PHP Data Objects) for PHP, is a popular application-independent API for accessing relational data on servers. ODBC is powerful -- allowing any SQL statement to be executed -- and simple, in the sense that developers are required to understand only a few abstractions. IBM Database Connectivity for JavaScript can be thought of as an "ODBC for Web clients," enabling Web developers to benefit from a general-purpose API for accessing relational data.
How does it work?
The IBM Database Connectivity for JavaScript implementation uses a "function-shipping" approach in contrast to actively processing a user's SQL on the client. The API allows clients to construct database and statement handles. Using a statement handle, developers can execute SQL, including queries, on the server. The query returns a result set to the client, which exposes an array of result-set rows, in which each row can be accessed on a per-column basis.
In the function-shipping approach, user invocations of the client-side API result in the following generic sequence of operations:
- The IBM Database Connectivity for JavaScript client library converts the API call to an XML message.
- The IBM Database Connectivity for JavaScript client library transmits the message to the IBM Database Connectivity for JavaScript gateway on the server.
- The IBM Database Connectivity for JavaScript gateway parses the client's message and constructs an invocation of the corresponding server-side API.
- The server-side API is invoked, and the results are evaluated.
- An XML message containing these results (for example, the result set for a query, an error condition, or an exception) is constructed and transmitted to the client.
- The IBM Database Connectivity for JavaScript client library parses the server's message and returns the API's corresponding result to the user.
The IBM Database Connectivity for JavaScript client library, in other words, is not a "smart" client: It doesn't, for example, try to validate whether a user's SQL is valid. If the SQL is invalid, the server will detect it and throw an exception or raise an error condition, and this result is returned to the user.
The server-side IBM Database Connectivity for JavaScript gateway is executed in a PHP container. The XML messages are translated into corresponding PDO method invocations and the method results are sent back to the client as XML messages. The client-side library interprets the message and returns the result to the user.
For further information, please see "DBC-JS: Middleware for secure Web-client access to relational data."
About the technology author(s)

Avraham Leff is a research staff member in the e-Business Frameworks department. He joined IBM in 1991. Dr. Leff's research interests include distributed components and distributed application development. He received a B.A. in computer science and mathematical statistics from Columbia University in 1984 and an M.S. and Ph.D. in computer science from Columbia University in 1985 and 1992, respectively. Dr. Leff has been issued six patents and has eight patents pending.

James Rayfield is a research staff member in the e-Business Frameworks department. He joined IBM in 1989. Dr. Rayfield""s research interests include transaction-processing systems and database systems. He received an Sc.B. in 1983, an Sc.M. in 1985, and a Ph.D. in 1988, all in electrical engineering from Brown University. Dr. Rayfield has seven patents issued and eight patents pending.
