-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave.java
39 lines (22 loc) · 809 Bytes
/
save.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
import java.sql.*;
public class save{
public save(){
}
public void contectDatabase(){
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/singleschool" , "root" , "Mohroh93"
);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM sc_staffdetails");
while (rs.next()){
System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getInt(3) + " " + rs.getString(4));
}
stmt.close();
con.close();
}catch (Exception e) {
System.out.println(e);
}
}
}