Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 
Training Index

Introduction to the JavaBeans API, Magercise 11
A JDBCTM Bean Database Manager

by John Zukowski, MageLang Institute

[Help | API Docs | Short Course | Magercises]

For this Magercise you use the BeanBox, or another IDE, to design and test a nongraphical JDBCTM Bean. The Bean makes a JDBC connection to a database server, after which it performs SQL operations as requested. You should design your Bean so that other users (programmers) can plug your JDBC Bean into their applications via an IDE.

Magercise 11 Prerequisites

Skeleton Code

Tasks

  1. The first task is to design and implement the DatabaseManager Bean with a no-argument constructor, plus access methods for properties for the typical configuration options and database interactions.

  2. Next, design and implement several methods that coordinate option processing with database connection and SQL operations:

  3. Next, create a database and load it with data.

  4. Design and implement a mechanism for displaying the data that's returned from a query, update, or general database operation.

  5. Create a separate test program (or add a main() to DatabaseManager.java) that tests the DatabaseManager Bean.

  6. If your executeSql() and connectToDB() are not no-argument methods with void returns, implement the appropriate control methods for point-and-click connection of command button actions to database operations, so that you can interact with a database from the BeanBox.

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

Demonstration

After loading the DatabaseManager Bean, it should appear in the palette, from where it can be selected and instantiated on the worksheet:

In this case, the worksheet contains a nongraphical DatabaseManager Bean and command buttons for connecting to and submitting a query, plus a TextArea specialization for displaying the results of a query.

The property sheet displays the published properties:

Magercise 12
Short Course
About This Short Course

Copyright © 1998-1999 MageLang Institute. All Rights Reserved.


[ This page was updated: 27-Oct-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.