-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadEmployee.java
43 lines (32 loc) · 972 Bytes
/
ReadEmployee.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
import java.sql.Connection;
//import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Scanner;
public class ReadEmployee {
public static void main(String[] args) {
try {
Connection conn= EmpDb.getEmpDb();
System.out.println("enter employee number:");
int eno = new Scanner(System.in).nextInt();
String sql="select *from employee where eno="+eno;
Statement st =conn.createStatement();
ResultSet rs= st.executeQuery(sql);
if(rs.next()){
System.out.println("Name "+rs.getString("Name"));
System.out.println("salary "+rs.getFloat("salary"));
System.out.println("Designation "+rs.getString("Designation"));
}
else
{
System.out.println("Employee not available");
}
rs.close();
st.close();
conn.close();
} catch (Exception e) {
// TODO: handle exception
System.out.println(e);
}
}
}