JDBC

JDBC is an application programming interface (API) included in the Java platform that enables Java programs to connect to a wide range of databases.

The AS/400 Toolbox for Java JDBC driver allows you to use JDBC API interfaces to issue structured query language (SQL) statements to and process results from AS/400 databases. The server also has a JDBC driver that is optimized for use on the server.

Begin changeWhen you are running an application on the server, your application uses the server JDBC driver by default. You can override this by using the driver property.End change

Different versions of JDBC

Begin changeDifferent versions of the JDBC API exist, and the AS/400 Toolbox for Java JDBC driver supports the following versions:

Supported interfaces

The table below lists the supported JDBC interfaces and the API required to use them:

Supported interface API required
Blob provides access to binary large objects (BLOBs) JDBC 2.1 core
CallableStatement runs SQL stored procedures JDK 1.1
Clob provides access to character large objects (CLOBs) JDBC 2.1 core
Connection represents a connection to a specific database JDK 1.1

Begin changeConnectionPool is a pool of database connections

JDBC 2.0 Optional PackageEnd change
DatabaseMetaData provides information about the database as a whole. JDK 1.1
Begin changeDataSources are factories for creating connections and a variety of objects.

JDBC 2.0 Optional PackageEnd change

Driver creates the connection and returns information about the driver version. JDK 1.1
PreparedStatement runs compiled SQL statements JDK 1.1
ResultSet provides access to a table of data that is generated by running a SQL query or DatabaseMetaData catalog method JDK 1.1

ResultSetMetaData provides information about a specific ResultSet

JDK 1.1

Begin changeRowSet is a connected row set that encapsulates a ResultSet

JDBC 2.0 Optional PackageEnd change
Statement runs SQL statements and obtains the results JDK 1.1

Begin changeXAConnection is a database connection which participates in global XA transactions

JDBC 2.0 Optional PackageEnd change
Begin changeXAResource is resource manager for use in XA transactions JDBC 2.0 Optional PackageEnd change

We have included a table that lists JDBC properties for easy reference.

Examples

The following examples illustrate ways to use the AS/400 Toolbox for Java JDBC driver.

Begin changeThe standard extension example includes registering objects by using a Java Naming and Directory Interface (JNDI) service provider. For more information on JNDI service providers, see AS/400 Toolbox for Java reference links.End change