CSE3330 Project #3

Application Coding
Thursday November 29, before midnight
Worth 13% of the final grade

You may do this project either on Omega (using Java or C) or on your PC/laptop (using Java on Windows, Mac OS X, or Linux).
Coding your Project on Omega

You may code your application program on Omega using either Java or C:

Coding in Java
Read the slides jdbc.ppt first, which explain JDBC. Download the jar file mysql-connector-java.jar on your omega account (at your top directory). Make sure that when you execute java -version you get "1.6.0_20". Then execute the following command every time you login into your omega account:
export set CLASSPATH=.:~/mysql-connector-java.jar:$CLASSPATH
(you may put this line at the end of your .login file so that you don't have to execute it every time). Then download mysql.java and change it to work on your database (change: user, password, db, and the query). You can compile it using javac mysql.java and you can run it using java SQL. Make sure that it works before you start coding your program.

Coding in C
You should first read MySQL C API. Then download mysql.c and change it to work on your database (change: user, password, db, and the query).
gcc -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient -lz mysql.c
Then, to execute it, you do ./a.out.

Coding your Project on your PC/laptop

You can do this project on your PC/laptop using Java. The following instructions are for Microsoft Windows, but you can do this project on Mac OS or Linux too. For Microsoft Windows, you need to do the following:

On Windows, open a Command Prompt window and type:
ssh2 -L 3300:localhost:3306 xyz9999@omega.uta.edu
(replace xyz9999 with your own net-ID). Give your net-ID password and keep this window open and connected to omega. If you get the message "Warning: Local TCP/IP forwarding for port 3306 port failed." you need to disable your PC firewall (eg, if you use Symantec, set Network Threat Protection to off).

You can compile the mysql.java using javac mysql.java. Every time you want to execute your java program, you need to do the following:

java -classpath "C:\Documents and Settings\Owner\Desktop\mysql-connector-java.jar";"." SQL
or wherever you stored the mysql-connector-java.jar file. If you get a Java error: "Exception in thread 'main' com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure", it means that your ssh2 connection has failed: login again using ssh2.

For Linux or Mac users: you can do the project on your computer, but you need to use ssh instead of ssh2 and : instead of ; in the classpath. For example, in Linux:

javac mysql.java
java -classpath ~/mysql-connector-java.jar:. SQL

CheapBooks is interested in an application program interface that is easy to use by customers. Although you will not build a web-based interface, you are expected to write a menu-based main program that consists of the following application functions for their daily transactions and is open for the inclusion of future programs.

Start customer session
Starts a new customer session with an empty shopping basket.

Search session
Allows the customer to search books by author name or by full title.

Purchase session
Asks the customer the ISBN number of a book to add it to her basket.

End customer session
Calculates the total cost, prints a summary of the cost (total cost), closes the customer's session, and creates the shipping orders to warehouses. The number of stocked books in the warehouses are updated accordingly. Finally, the shopping basket is removed.

New customer
Adds a new customer.

The application program should use an ASCII interface (ie. by reading input text from the terminal and printing out text to the terminal), but it must be menu-based (eg. it may provide choices by number and ask the user to choose a number). For example, it may say: "type 1 to start a customer session, type 2 to search ...", and then may ask other info, such as customer name, etc.

What to Submit

You must handin your source code (the java or C files only) and the printout of an example session where you execute each one of the above 5 application sessions at least once. (You may cut and paste your program I/O into a text file.) You must use the following form to submit your files electronically. You may submit them as many times as you like, but only the most recently submitted file will be retained and evaluated.

Submit Project #3:

Last modified: 10/23/12 by Leonidas Fegaras