You are on page 1of 1

A

S
S
IDEA LABS Assignment - 11 I
G
Note: While doing the following task, you should keep in mind to handle / declare the N
Exceptions and to close the Database Connection. M
E
Write a simple Java application to connect and interact with a database. The program will N
first connect to the previously created company database, print all employees on the T
screen and make some modifications on the employee records. Finally, it will print all
employees once again. The steps are explained in more detail in the below.

1) Create DSN and successfully connect to your company database using JDBC.

2) Execute the command “SELECT * FROM employee” and print the results.

3) Next, insert the following records into Employee relation. To achieve this, you can use
either Statement or PreparedStatement object of Java.

Emp_no Name Skill Pay_rate DOB Join_Yr Address City

1 tony manager 22.5 18.02.1960 18.04.1980 johson st. chicago

2 jill driver 8 07.05.1978 17.02.2000 ciflik istanbul

3 john worker 9.7 12.09.1970 22.04.1995 avenue st. chicago

4 kemal typing 11.5 25.06.1916 01.12.1991 besevler istanbul

5 mike worker 20 06.05.1965 06.05.1995 seasem st. london

4) Execute the command “SELECT * FROM employee” and print the results.

5) Update the contents of the employee relation as follows:


• For all employees who have skill manager, set the pay rate to 50. For all others, set
the pay rate to 10.
• For all employees who have joined the company after 1975, increase the pay_rate
by 20%.

6) Delete all employees who have joined the company before 01/01/2000 and have the
skill “worker” (both), or date of birth less than 01/01/1965.

7) Execute the command “SELECT * FROM employee” and print the results.

8) Can we get a Null ResultSet? Illustrate with a code snippet.

9) Consider the following:


Connection con = DriverManager.getConnection(String url);

Here Connection is an interface, so what will be the class name of connection object
in this case? What do you infer? Hint: Use method’s getClass() and getName().

Renaissance softl
softlabs
oftlabs Pvt. Ltd. Page 1 of 1

You might also like