-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateEmployee.java
44 lines (35 loc) · 1004 Bytes
/
UpdateEmployee.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
43
44
import java.sql.Connection;
import java.sql.Statement;
import java.util.Scanner;
public class UpdateEmployee {
public static void main(String[] args) {
try {
Connection conn =EmpDb.getEmpDb();
Scanner sc = new Scanner(System.in);
System.out.println("enter name");
String name =sc.next();
System.out.println("enter eno");
int eno = sc.nextInt();
System.out.println("enter Designation");
String ds =sc.next();
System.out.println("enter salary");
float salary =sc.nextFloat();
sc.close();
String sql = "update employee set name = '"+ name +"',salary="+salary+",designation ='"+ds+"' where eno="+eno;
Statement st=conn.createStatement();
if(st.executeUpdate(sql)>0)
{
System.out.println("sucess");
}
else
{
System.out.println("not available");
}
st.close();
conn.close();
} catch (Exception e) {
// TODO: handle exception
System.out.println(e);
}
}
}