Question: in this question, you develop a JDBC program, called Users, that adds and checks user login information in a database table. The table, called A2Users,

 in this question, you develop a JDBC program, called Users, that

in this question, you develop a JDBC program, called Users, that adds and checks user login information in a database table. The table, called A2Users, has two columns: Name CHAR(30) and Password CHAR(32). The Name column contains the user name; it is the primary key of the table and is therefore unique. The Password column contains the MD5 message digest of the password, in hex-digit format, e.g. the two digits 1F stands for the byte value 31 (= 16+15). The following SQL command creates the table.

In this question, you develop a JDBC program, called Users, that adds and checks user login information in a database table. The table, called A2Users, has two columns: Name CHAR(30) and Password CHAR ( 32). The Name column contains the user name; it is the primary key of the table and is therefore unique. The Password column contains the MD5 message digest of the password, in hex-digit format, e.g. the two digits '1F stands for the byte value 31 (= 16+15). The following SQL command creates the table. CREATE TABLE A2Users (Name CHAR(30) PRIMARY KEY, Password CHAR(32)); The program has three command-line arguments: the operation to perform (either - add or - check), the user name, and the password. For either operation, the 16-byte MD5 message digest of the password is computed, and converted to a string of 32 hex digits. If the first argument is -add, the program adds a record with the user name and the password digest to the table, and displays a confirmation message. If the first argument is -check, the program checks the user name and password digest against the table records, and displays a "YES or NO message according to whether a matched record exists. In case of any exception or error, an error message is shown. You may use these SQL commands in the program: INSERT INTO A2Users (Name, Password) VALUES (?, ?) SELECT COUNT(*) FROM A2Users WHERE Name = ? AND Password = ? Use the JDBC connection data in Unit 4, i.e. database COREJAVA, user name dbuser, and password secret. These are sample outputs of running the program. > java a2. Users -add peter peterpass User peter added. > java a2. Users -add peter peterpass The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL200309122824270' defined on 'A2USERS'. > java a2. Users -check peter peterpass Authenticating user peter: YES > java a2.Users -check peter badpassword Authenticating user peter: NO

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!