-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDesgSalaries.java
42 lines (35 loc) · 1.16 KB
/
DesgSalaries.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class DesgSalaries {
public static void main(String args[])
{
try{
Connection con=UtilityClass.connect();
String sql="select * from employee";
PreparedStatement pt=con.prepareStatement(sql);
ResultSet rs=pt.executeQuery();
int seSal=0;
int stSal=0;
int pmSal=0;
int tlSal=0;
while(rs.next()==true)
{
String desg=rs.getString("desg");
int sal=rs.getInt("sal");
switch(desg)
{
case "SE" -> seSal+=sal;
case "ST" -> stSal+=sal;
case "PM" -> pmSal+=sal;
case "TL" -> tlSal+=sal;
}
}
System.out.println(seSal+" "+stSal+" "+pmSal+" "+tlSal);
con.close();
}catch(Exception ex)
{
ex.printStackTrace();
}
}
}