| CIT
597 Assignment
9: Using JDBC Fall 2005, David Matuszek |
Create a database of courses you have taken and/or would like to take. Use
a Java GUI to add courses and SELECT information from the database.
You should already have MySQL installed.
Go to http://dev.mysql.com/downloads/connector/j/3.1.html
and download Connector/J. Unzip it. Put the .jar file somewhere
Java can find it (In Eclipse: Project --> Properties --> Java Build
Path --> Libraries --> Add External Jars...).
Write a program with a GUI that will allow me to:
Create Table button) of courses
you have taken, or maybe would like to take. You can use the following code
as a example of how to create and populate a table:
Statement s = conn.createStatement ();
s.executeUpdate ("DROP TABLE IF EXISTS animal");
s.executeUpdate ("CREATE TABLE animal ("
+ "id INT UNSIGNED NOT NULL AUTO_INCREMENT,"
+ "PRIMARY KEY (id),
+ "name CHAR(40), category CHAR(40))");
int count;
count = s.executeUpdate ("INSERT INTO animal (name, category)"
+ " VALUES"
+ "('snake', 'reptile'),"
+ "('frog', 'amphibian'),"
+ "('tuna', 'fish'),"
+ "('racoon', 'mammal')");
s.close ();
|
CIT597) as a primary key
(note that you will need to change the way the primary key is defined), and
have three or four additional fields of your choice. Add button.SELECT from the table. Give the user a couple
of options, and be sure you can select newly added records. However, don't
try for full generality! Again, think "proof of concept".For full credit, you do not need to write a beautiful, useful program. Your goal should be to demonstrate that you can create, update, and access a database from Java using JDBC. Think of this as the "Hello World" of JDBC programming.
Thursday, December 8, before midnight.