Write a JAVA application in a client/server environment.
Write a JAVA application that allows users to update their personal information in a database in a client/server environment.
Windows:
Window 1:
Window1 should allow the user to select between two options ADD or UPDATE. It should contain two buttons and based on the user selection the user should be prompted with either Window2 or Window3.
Wnidow2: ADD
If the user selects ADD from the first window then he/she should be prompted by window2, which contains the following fields:
• STD ID
• First Name
• Last Name
• Age
• Gender
When the user fills all fields and clicks on the button ADD, then all field values should be written through a socket to the server class that receives them and pass them to the DB class which in turn adds them to the table/Sheet.
To add a record to the DB table(users) , then use the following code:
String query = "insert into users values('1234','Mohammad','Ahmad','50','M')";
try {
Statement stmt = DB_Conn.createStatement();
int rs = stmt.executeUpdate(query);
} //end try
Wnidow3: Update
If the user selects UPDATE from the first window then he/she should be prompted by window3, which contains the following fields:
• STD ID
• First Name
• Last Name
• Age
• Gender
When the user fills the fields and clicks on the button UPDATE, then all field values should be written through a socket to the server class that receives them and pass them to the DB class which in turn updates an existing record with the new values.
If the user wants to update an existing record then when the user fills the form fields the STD ID field value must match the value of an existing record in the DB. Your program should only update that record in the DB
To update an existing record to the DB table (users) , then use the following code:
String query ="UPDATE users SET age=100 WHERE name='A' ";
try {
Statement stmt = DB_Conn.createStatement();
int rs = stmt.executeUpdate(query);
} //end try
Important notes and guidelines.
1. You should use Access DB no EXCEL
2. The database name should be second.mdb
3. The DB should contain one table called “users” with the following fields
a. Std_id
b. First_name
c. Last_name
d. Age
e. Gender
4. How to setup the DB System name
a. Go to Control Panel >> Administrative Tools >> Data Sources (ODBC)
b. Go to System DSN tab
c. Click on Add
d. Select Microsoft Access Driver (*.mdb) and click on Finish
e. In Data Source Name insert ABC
f. Click on SELECT and select your database “Second.mdb” created in step 2
g. Click OK
|