Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python
C++

JAVA


PHP
SQL
Alice

DBExample2


Description

Run it
Download jar file (Right click)

BowlingModel.java
DBExample2.java

Description
DBExample2 is a more complicated applet that demonstrates how to connect to a MySQL database and perform a multiple queries in JAVA.

The applet serves several purposes:

  • An example of how to use a few operations from the ResultSet class.
  • An example of how to do multiple queries from a database.
  • An example of one way to use a ResultSet in a TableModel so the data can be displayed in a JTable relatively easily.
  • An example of a somewhat complicated query, joining 5 tables.

In order to run the applet, two things are needed. First, you need a driver to connect between JAVA and MySQL. This can be obtained from SourceForge.net. Second, for security reasons, the applet needs to live on the same machine as the MySQL server. There may be ways around this, but it is more work than I care to deal with for now.