-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathSimpleDual2.java
More file actions
52 lines (46 loc) · 1.62 KB
/
SimpleDual2.java
File metadata and controls
52 lines (46 loc) · 1.62 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
40
41
42
43
44
45
46
47
48
49
50
//
// Standard disclaimer - anything in here can be used at your own risk.
//
// It is very likely you'll need to edit the script for correct usernames/passwords etc.
//
// No warranty or liability etc etc etc. See the license file in the git repo root
//
// *** USE AT YOUR OWN RISK ***
//
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.sql.Timestamp;
import java.time.ZonedDateTime;
import oracle.jdbc.internal.OraclePreparedStatement;
public class SimpleDual2 {
public static void main(String[] args) {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
int v1;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:scott/tiger@//localhost:1530/pdb21a");
long startTime = System.nanoTime();
PreparedStatement pstmt = con.prepareStatement("select 1 x from dual");
for (int obj = 1; obj <= 200000; obj++)
{
rs = pstmt.executeQuery();
while(rs.next()) {
v1 = rs.getInt(1);
}
}
pstmt.close();
long duration = ( System.nanoTime() - startTime ) / 1000000;
System.out.print("200000 iterations, " + duration + " ms\n");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
}