Due: see class web page
mkdir ~/cs377/JDBC cp /home/cs377001/Handouts/JDBC/JDBC.java ~/cs377/JDBC |
|
The project is done by extending the prepared program file JDBC.java with the above functionalities
The prepared program file JDBC.java contains TODO labels in the following places where you must:
|
In the prepared file JDBC.java, I have written code to activate the SELECT button
(And in class, I have discuss how to write call back code)
javac -cp ".:/home/cs377001/lib/mysql-connector-java.jar" JDBC.java java -cp ".:/home/cs377001/lib/mysql-connector-java.jar" JDBC |
Note:
|
The GUI looks similar (but "less professional") than the cs377-sql query tool that you used in the SQL project
In this project, you will learn to implement the cs377-sql query tool by yourself....
|
These 6 buttons are highlighted in yellow in this figure:
How to work on this project:
|
Functionality of the main method and the call back methods for the buttons:
|
The following are required output format of the GUI:
|
Test output
1. Select the spjDB database 2. Execute this query: select * from JDBCTest |
The output must look like this:
name address salary dnum really_lon ================================================================ John 123 Decatur Rd 50000.1000 5 NULL Mary 543 Fishburn Rd 40000.9500 NULL abcde NULL 765 West Lane NULL 1 0123456789 David NULL 60500.5000 0 NULL Peter 890 Oxford Dr 30510.5600 3 klm Jane 672 Turn lane 22540.3500 2 xyz Jack 444 Watts Dr 83501.5990 3 NULL William 123 ABC lane 46500.2500 2 abc |
|
|
To store the attribute value, do:
|
|
|
Applicablity criteria:
|
Simplifcation:
|
Use the length() method to find the length of the string.
The display size of the column is obtained from the meta data
Note:
|
The number of decimal places displayed must be equal to the value returned by getScale().
The Java class java.text.DecimalFormat can help you format numbers.
For example, the following program shows you how to format a double number:
import java.text.DecimalFormat; class TestFormat { public static void main(String args[]) { double myNumber = 1234.5678; DecimalFormat form = new DecimalFormat("0.00"); String s; s = form.format(myNumber).toString(); System.out.println(s); } } |
will print:
1234.57The format string "0.00" will produce an output with 2 decimal places. If you use the format string "0.000", it will print 1234.568.
The string that you obtained does not have the correct length. You will still need to pad the (numberic) string in front with the exact number of spaces to align the string to the right !
|
Point assignments to the project:
|
If your program consists of a single Java program file, then do the following:
/home/cs377001/turnin JDBC.java JDBC |
If your program consists of multiple Java program files, then do the following:
|
Extension request
/home/cs377001/req-ext JDBC |
You request will be successful if you have not exceeded the maximum number of "free" (no-questions-asked) requests allowed
Students will be graded partially on the basis of their programming assignments. These programming assignments are to be treated as examinations, and are expected to be your individual work. While discussions with other students in the course may be permitted or encouraged by your instructor, you should write your program yourself. The mathlab representatives are available to explain error messages, discuss briefly technical details with which you may not be familiar, and give short suggestions as to how you might detect logic errors. The reps should not, however be asked to write part or all of your program. Your instructor (and any teaching assistants assigned to the course) will be glad to help you to the extent that he or she feels reasonable.
Submissions based on other students solutions in prior offerings of the course specifically violate these guidelines, as do submissions prepared with the help of an outside "tutor".
You should take precautions to protect the confidentiality of your work: preserve the secrecy of your password, do not make files or directories sharable, pick up your printouts promptly and dispose of printouts where they will not tempt other students. All work should be done either in the class directory of your ITD account (preferred) or in your "priv" directory (only if you do not have a class directory).
All submissions should include a comment statement near the top of the program of the form:
THIS CODE IS MY OWN WORK, IT WAS WRITTEN WITHOUT CONSULTING A TUTOR OR CODE WRITTEN BY OTHER STUDENTS - your name
Cases of apparent plagiarism or collusion will be referred to the Honor Council.