-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEmployeeJdbc.java
More file actions
31 lines (24 loc) · 854 Bytes
/
EmployeeJdbc.java
File metadata and controls
31 lines (24 loc) · 854 Bytes
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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.io.*;
public class Employee {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Connection con = DriverManager.getConnection("jdbc:h2:tcp://localhost/~/test","sa","");
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Enter Employee Id:");
int empId = Integer.parseInt(br.readLine());
String query = "delete from Employee where EMPID = ? ";
PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, empId);
ps.execute();
System.out.println("Success");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}