The JavaTM Tutorial

| Start of Tutorial | Search Feedback Form

## Trail: JDBC(TM) Database Access

### by Maydene Fisher

JDBCTM was designed to keep simple things simple. This means that the JDBC API makes everyday database tasks, like simple `SELECT` statements, very easy. This trail will walk you through examples of using JDBC to execute common SQL statements, letting you see for yourself how easy it is to use the basic JDBC API.

This trail is divided into two lessons:

JDBC Basics covers the JDBC 1.0 API, which is included in JDK tm 1.1. The second part covers the JDBC 2.0 API, which is part of the JDK 1.2 release. It also briefly describes the JDBC extension API, which, like other standard extensions, will be released independently.

By the end of the first lesson, you will know how to use the basic JDBC API to create tables, insert values into them, query the tables, retrieve the results of the queries, and update the tables. In this process, you will learn how to use simple statements and prepared statements, and you will see an example of a stored procedure. You will also learn how to perform transactions and how to catch exceptions and warnings. In the last part of this lesson, you will see a how to create an applet.

New Features in the JDBC 2.0 API teaches you how to move the cursor in a scrollable result set, how to update result sets using the JDBC 2.0 API, and how to make batch updates. You will also learn about the new SQL3 datatypes and how to use them in an application written in the Java tm programming language. The final part of this lesson gives you a preview of the JDBC extension API, with features that let you take advantage of JavaBeans tm technology and Enterprise JavaBeans tm technology.

This trail will not cover how to use the metadata API, which is used in more sophisticated programs, such as applications that must dynamically discover and present the table structure of a target database.

> Note:

> Available now from amazon.com | The material on the JDBC 1.0 API is excerpted from the first edition of JDBC Database Access with Java: A Tutorial and Annotated Reference, published by Addison Wesley Longman, Inc., and written by Graham Hamilton, Rick Cattell, and Maydene Fisher. For more complete information about the JDBC 2.0 API and the JDBC extension API, see the second edition, JDBCTM API Tutorial and Reference, Second Edition: Universal Data Access for the Java 2 Platform written by Seth White, Maydene Fisher, Graham Hamilton, Rick Catell, and Mark Hapner. Published by Addison Wesley Longman, Inc. June 1999.

| Start of Tutorial | Search Feedback Form

Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.