Java was introduced in 1995; it was originally intended as a language for small electronic devices such as cellular telephones. It quickly evolved into the Web-oriented, “write once, run anywhere” powerhouse it is today, thanks partly to the addition of Java Database Connectivity (JDBC) and JDBC drivers, which allow Java to dynamically access data stored in relational databases. Enabling database access allowed Java to quickly supplant more cumbersome, less stable languages such as C and C++. This article examines Java and JDBC technology, including the associated drivers, and how they’re integrated into IBM’s flagship relational database product, DB2 for z/OS Version 9.1.
Where does JDBC come into play? JDBC lets Java access and manipulate data in relational databases, such as DB2, Oracle, MySQL, etc., for which there exists a JDBC driver. Originally, database access wasn’t a significant consideration in developing Java applications; the language was intended for small, embedded systems. As the focus of Java shifted to Web-oriented programming, database access became increasingly important, and the need for such access across disparate database platforms became apparent to all.
JDBC is similar in concept to Microsoft’s Open Database Connectivity (ODBC). Both ODBC and JDBC are based on the European X/Open consortium (now part of The Open Group) standard for database connectivity. The JDBC Application Program Interface (API) is actually two major sets of interfaces and classes written in Java. The first set is the JDBC API for application developers; the second is a lower-level JDBC driver API for driver developers.
There are several advantages of JDBC technology:
• The ability to leverage existing data: Businesses aren’t locked into any single proprietary architecture.
• Simplified development: Java and JDBC in combination make development easier than with other architectures because JDBC hides the complexity of many data access details.
• No configuration required for networked computers: No configuration is necessary on the client side. All information needed to make a connection is defined by the JDBC Uniform Resource Locator (URL), or a DataSource object that’s registered with a Java Naming and Directory Interface (JNDI) naming service. Using a DataSource object is the better of the two methods because it makes the code more portable and easier to maintain.
There are four types of JDBC drivers: