-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRead.java
More file actions
31 lines (20 loc) · 728 Bytes
/
Read.java
File metadata and controls
31 lines (20 loc) · 728 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.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Read {
private Statement statement;
public Read(Statement statement) {
this.statement = statement;
}
public void read() throws SQLException {
ResultSet resultSet = statement.executeQuery("select * from Books"); /////////// read
while(resultSet.next()){
System.out.println(resultSet.getInt(1));
System.out.println(resultSet.getString(2));
}
ResultSet resultSet1 = statement.executeQuery( "select name from Books where id = 1");
while (resultSet1.next()){
System.out.println(resultSet1.getString(1));
}
}
}