Sun Java Solaris Communities My SDN Account
 
Tutorials & Code Camps

JDBC Exercises

 

Training Index


[Table of Contents]

Welcome to the JDBC exercises. These exercises show how to use JDBC to connect to a relational database, how to send SQL queries to the database and how to collect and process the results of a query. There are also exercises on how to look at the metadata of a database (the structure of the tables in the database) and how to use sockets to allow communication between a secure applet and a remote database.

There are nine exercises to complete:

  1. Getting Started
    This exercise shows how to create a data source to use with ODBC.

    Educational goals:

    • Learn about different types of ODBC datasources.
    • Learn how to create an ODBC datasource.

  2. JDBCTest Introduction.

    This exercise shows how to use the JDBCTest application to test the JDBC-ODBC bridge.

    Educational goals:

    • Learn about JDBC drivers.
    • Learn how to use JDBCTest to get metadata from the database.

  3. Connecting to an ODBC datasource without JDBCTest.

    This exercise shows how to connect to an ODBC data source using only Java code.

    Educational goals:

    • Learn how to load a JDBC driver in Java.
    • Learn about the Java DriverManager class.

  4. Connecting with Properties.

    This exercise shows how to connect to a database using properties.

    Educational goal:

    • Learn how to change datasources without recompiling.

  5. Selecting.

    This exercise shows how to execute SQL statements, and use the results to build a chart.

    Educational goals:

    • Learn how to execute a SQL select statement.
    • Learn how to process the results of a database query.
    • Learn to use the NetCharts package to build a chart.

  6. Using MetaData.

    This exercise shows how to get information about the structure of a database.

    Educational goals:

    • Learn how to get database metadata from the results of a query.
    • Learn how to process the database metadata.

  7. Command-Line Guestbook.

    This exercise, builds a simple application that operates as a guestbook, allowing users to enter new comments and view previous comments.

    Educational goals:

    • Learn how to execute SQL select statements.
    • Learn how to use the findColumn method.
    • Learn how to execute a prepared SQL update statements.

  8. Applet Guestbook.

    This exercise, an extension of the previous one, adds an applet to present a GUI interface to the guestbook.

    Educational goal:

    • Learn how to use sockets to connect an Applet safely to a remote database.

  9. SQL Warning/Exception Handling.

    This exercise deals with something we've been mostly ignoring in all the other exercises, warnings, exceptions, and errors.

    Educational goals:

    • Learn how to detect and handle runtime SQL warnings and exceptions.
    • Learn how to use DatabaseMetaData to avoid some of them.

Copyright © 1996 Magelang Institute. All Rights Reserved.

Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.