Database help in java

I'm currently in a java class this semester, the project we are supposed to do is print out in a Applet a list of people. She wants us just using drawStrings but that to me don't teach Crap. So I thought I'd add a database made in Microsoft Works Database. Below is the program and where and what the errors are. I tried the java board but no help yet there. IF someone can help I'd appreciate it. Thank you,

import java.sql.*;
import javax.swing.*;// Error #1 here package swing not found
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import java.lang.*;

public class databApp extends JFrame{ //Error #2 here super class of jFrame not found

private JTable DataTable;
private Connection Database;

public databApp () {
String url = "jdbc:odbc:customers";
String userID = "John";
String password = "settle";
Statement DataRequest;
ResultSet Results;

try {
Class.forName( "sun.jdbc.odbc.jdbcOdbcDriver");
Database =
catch (ClassNotFoundException error) {
System.err.println("Cannot connect to the database." + error);
catch (SQLException error){
System.err.println("Cannot connect to the database" + error);
try {
String query = "Select * FROM customer";
DataRequest = Database.createStatement();
Results = DataRequest.executeQuery (query );
DisplayResults (Results );
catch (SQLException error ) {
System.err.println("SQL eroor." + error);
setSize (500,200);

private void DisplayResults (ResultSet DisplayResults)throws SQLException
boolean Records =;

if (!Records ) {
JOptionPane.showMessageDialog( this, "End of Data.");
setTitle ( "Process Completed");
setTitle ("CUSTOMER NAMES");
Vector ColumNames = new Vector();
Vector rows = new Vector();
try {
ResultSetMetsData MetaData = DisplayResults.getMetaData();

for (int x =1; x <= MetsData.getColumnCount(); ++x)
ColumnNames.addElement (MetaData.getColumnName(x));

do {
rows.addElement (DownRow(DisplayResults, MetaData ));
} while (;

DataTable = new JTable ( rows, ColumnNames );
JScrollPane scroller = new JScrollPane ( DataTable);
getContentPane().add(scroller, BorderLayout.Center);
catch (SQLException error ) {
System.err.prntln("Data display error." + error);
private Vector DownRow (ResultSet DisplayResults, ResultSetMetaData MetaData)
throws SQLException
Vector currentRow = new Vector();
for (int x = 1; x <= MetaData.getColumnCount(); ++x)
switch ( MetaData.getColumnType (x)){
case Types.VARCHAR :
return currentRow;
public void Disconnect()
try {
catch (SQLException error){
System.err.println("Cannot break connection." + error);
public static void main ( String args[])
final conxtest link = new conxtest();
link.addWindowListener (
new WindowAdapter() {
public void windowClosing(WindowEvent WinEvent )
System.exit (0);

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!