Question: JAVA coding Question 1 - Database [30 marks] In this question, you develop a JDBC program, called Users, that updates user login information in a

 JAVA coding Question 1 - Database [30 marks] In this question, JAVA coding

Question 1 - Database [30 marks] In this question, you develop a JDBC program, called Users, that updates 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 four command-line arguments: the operation to perform (-update), the user name, the old password and the new password. For the update operation, the 16-byte MD5 message digest of the old and new passwords are computed, and converted to a string of 32 hex digits. If authentication is successful, the program updates the old password digest of the record with the new password digest to the table, and displays a confirmation message "Password has been updated.". If incorrect number of arguments or the first argument is not "-update", message "Usage: java -option name old-password new-password." is displayed. If the new password same as the old password, message "New password cannot be the old password." is displayed. In case of any exception, the program catches and displays the exception. You may use these SQL commands in the program: SELECT COUNT (*) FROM A2Users WHERE Name = ? AND Password = ? UPDATE A2Users SET Password = ? WHERE Name = ? 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 -update peter peterpass Usage: java -option name old-password new-password. > java a2. Users update peter peterpass newpeterpass Usage: java -option name old-password new-password. > java a2.Users -update peter peterpass peterpass New password cannot be the old password. > java a2.Users -update amy peterpass newpeterpass Invalid name or password. > java a2.Users -update peter peterpass newpeterpass Password has been updated

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!