Database application developers use JDBC, the application programming interface that makes it possible to access relational databases from Java programs. The JDBC API is part of the Java 2 Platform, Standard Edition (J2SE) and is not specific to any particular database implementation, such as Apache Derby or DB2® Everyplace®. It consists of the java.sql
packages, which are sets of classes and interfaces that make it possible to access databases (from a number of different vendors) from a Java application.
The JDBC specification defines several interfaces and types that application developers use to access the database.
- A DataSource is the primary definition of a database, and typically defines database access properties and locations.
- A Connection is the communication object that enables queries and updates to be performed against the database. The preferred method for obtaining a connection in JDBC 3.0 is with a DataSource object, as opposed to using DriverManager in a JDBC 2.0 specification implementation.
- A Statement enables the application developer to affect specific actions on the database. There are specialized types known as PreparedStatement or CallableStatement that provide additional advantages and capabilities. A Statement is created from a Connection object.
- A ResultSet represents the result of a query. The ResultSet object is returned upon successful execution of a query in a Statement.
As previously mentioned, the JDBC APIs are part of the J2SE specification. In order to get a clear picture of the current JDBC APIs it is useful to review the history of them and their relationship to the J2SE specification. J2SE 1.2 defined JDBC 2.0, which included definitions in the java.sql package. The main way of accessing databases was with the java.sql.DriverManager
interface. Sun then defined the JDBC 2.0 extension package, which introduced the javax.sql
package and a new DataSource interface for accessing databases in Java, as well as support for connection pooling. JDBC 3.0 was subsequently defined and combined the two components of JDBC 2.0 into one JDBC specification. This was first included in J2SE 1.4.
In addition to knowledge of the development of JDBC APIs, database application developers also need to have a detailed understanding of the Structured Query Language (SQL). SQL is the standard query language used with relational databases and is not tied to a particular programming language. No matter how a particular relational database management system (RDBMS) has been implemented, the user can design databases and insert, modify, and retrieve data using the standard SQL statements and well-defined data types. SQL-92 is the version of SQL standardized by ANSI and ISO in 1992. Entry-level SQL-92 is a subset of full SQL-92 specified by ANSI and ISO that is supported by nearly all major DBMSs today. In 1999, another update to the SQL standard was made available called SQL-1999 or SQL-99.
Parent topic: Understanding embedded database development: XPD622