-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path_15.jdbc.java
More file actions
31 lines (27 loc) · 867 Bytes
/
_15.jdbc.java
File metadata and controls
31 lines (27 loc) · 867 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.*;
public class GFG {
public static void main(String[] args)
{
Connection con = null;
PreparedStatement p = null;
ResultSet rs = null;
con = connection.connectDB();
// Try block to catch exception/s
try {
String sql = "select * from cuslogin";
p = con.prepareStatement(sql);
rs = p.executeQuery();
System.out.println("id\t\tname\t\temail");
while (rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
String email = rs.getString("email");
System.out.println(id + "\t\t" + name
+ "\t\t" + email);
}
}
catch (SQLException e) {
System.out.println(e);
}
}
}