Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information JDC Resources DukeDollars

Java Cup Logo

JDC Home Page

JDC Applets
(chat, newsreader, calendar)

Log Out

Online Training
shadowSearchFAQFeedback

Course Notes Table of Contents | Exercises
JDBC Short Course Index | Online Training Index

MageLang: JDBC exercises
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 © 1997 MageLang Institute. All Rights Reserved
May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved