In this assignment, you will interact with a database through queries using Java Database Connectivity (JDBC) to perform SQL Queries. You will modify a java program (QueryInterface.java) to establish a connection to the database, query the database, and display the results/errors of the query.
You can learn more about how to interact with a database through JDBC in the JDBC trail of the Java tutorial.
You should read the Readme.txt provided with the OracleTM
software for issues specific to JDBC connectivity with Oracle. This can be
found at the path $ORACLE_HOME/jdbc/Readme.txt after you log into bulldog
server. You need to set up the environment in order to compile and run JDBC
programs for Oracle. Add $ORACLE_HOME/jdbc/lib/classes12.zip to your CLASSPATH
and add $ORACLE_HOME/jdbc/lib to your LD_LIBRARY_PATH. This can be done as
follows for C shell:
set CLASSPATH=($ORACLE_HOME/jdbc/lib/classes12.zip $CLASSPATH) set LD_LIBRARY_PATH=($LD_LIBRARY_PATH $ORACLE_HOME/jdbc/lib)You can add these lines to your initialization script.
To view the GUI (after running the QueryInterface class) you need to
be connected to the bulldog server via a X-Client. You can find a X-Client
software installed on the machines in MWAH 177 lab. Connect using the X-Client
software to bulldog server by providing your login and password and then
execute the java program as follows:
java QueryInterface
The Star Wars Query Interface program provides a framework to perform some interesting queries on the Star Wars database we used in the first assignment. The query interface program provides the framework for your program to interface with the Star Wars database. It contains the skeleton to implement 5 different queries on the database. These queries are as follows:
The Star Wars Query Interface program is a menu driven application for querying the Star Wars database. There are two menus: Query and Connection. The Query Menu contains links to the various queries provided by the interface, and the connection menu provides functionality to connect to and disconnect from a database.
The panels to query the database do not appear unless you connect to the database. After you connect to the database, you can perform various queries on the database by clicking the queries in the Query menu.
The Star Wars Query Interface program provides the code for the GUI and handling various error condtions (but not all). You have to modify the code the add the database interaction to the application using JDBC. A simple way to find where you should modify the code is to search for the word EDIT in the source code.
In all you will need to modify 12 functions, which are described as follows:
create table votes ( username varchar2(20), character varchar2(20) )
Turn in a paper copy of your code.
You will also need to submit an electronic copy of your code (both source and compiled code so we can test). To do so you should put your code in a subdirectory prog02 under a subdirectory corresponding to your login. For example, if your login is rmaclin, you code should be in a directory rmaclin/prog02. The java source files in this directory should end in .java. To submit your code you should tar the file as follows: