-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathGetAll.java
More file actions
39 lines (30 loc) · 1.02 KB
/
GetAll.java
File metadata and controls
39 lines (30 loc) · 1.02 KB
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
package movie;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;
/**
* Gets all the JSON values from the movie table.
*
* <p>
* Run first: {@link CreateTable}, {@link Insert}
* </p>
*/
public class GetAll {
public static void main(String[] args) throws SQLException {
PoolDataSource pool = PoolDataSourceFactory.getPoolDataSource();
pool.setURL(String.join("", args));
pool.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
try (Connection con = pool.getConnection()) {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT data FROM movie");
while (rs.next()) {
String text = rs.getObject(1, String.class);
System.out.println(text);
}
rs.close();
}
}
}