Database Java Labs
Here are some examples to get you going with databases on a Microsoft OS. See also Getting Started for an odbc:jdbc example (using Windows 95/NT4.0). Also note that for Windows 2000, see below
I did not have to download a JDBC:ODBC driver or put it in my CLASSPATH. Must be in the JDK download for Windows.
-
SimpleSelect.java Description: Test
program for ODBC API interface. This java application
will connect to a JDBC driver, issue a select statement
and display all result columns and rows This code should work. The Exam code GUI below needs some edits due to an old version of java. So, test with SimpleSelect first.
-
Exam.java A multiple choice exam application that
relies on a database for the questions, choices, and answers. But, you need
to check the comments and edit them to run as on the database used in the
SimpleSelect class.
-
ResultsDialog.java and WrappingLabel.java are classes used by
Exam.java
Both Exam.java and ResultsDialog.java are 1.0 code. This is also left
to the reader to convert. (Such experience is good for you)
- testDB.mdb is an access database that
can be used for the above code
To register your database in Windows 2000 +:
- Bring up Control Panel
- Select the Start button
- Select the Settings menu item
- Select the Control Panel menu item
- Select the Administrative Tools directory
- Find and double-click on the DataSources (ODBC) icon.
This brings up the 'ODBC Data Source Administrator' window. Should be under 'User DSN'
- Select Add. This brings up the Create New Data Source window.
- Select the driver for the type of driver you want
If you selected Text, the ODBC Text Setup window appears.
- Name the data source mage.
- Fill in a description.
- Select the directory in which you placed files from the initial task.
- Select OK to accept new driver.
If you selected Microsoft Access, the ODBC Microsoft Access Setup window appears.
- Name the data source my-dsn (see the SimpleSelect example ).
- Fill in a description.
- Click on the Select button to bring up a file dialog.
- Locate the directory where your file is. (e.g., the database above that is converted for the newer Access in 2000)
- Select OK to accept new driver.