comparison tests/Test_PSlargeamount.java @ 0:a5a898f6886c

Copy of MonetDB java directory changeset e6e32756ad31.
author Sjoerd Mullender <sjoerd@acm.org>
date Wed, 21 Sep 2016 09:34:48 +0200 (2016-09-21)
parents
children 04fbf3655452
comparison
equal deleted inserted replaced
-1:000000000000 0:a5a898f6886c
1 /*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
7 */
8
9 import java.sql.*;
10 import java.util.*;
11
12 /* Create a lot of PreparedStatements, to emulate webloads such as those
13 * from Hibernate. */
14
15 public class Test_PSlargeamount {
16 public static void main(String[] args) throws Exception {
17 Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
18 Connection con = DriverManager.getConnection(args[0]);
19 Statement stmt = con.createStatement();
20 PreparedStatement pstmt;
21
22 // >> true: auto commit should be on
23 System.out.println("0. true\t" + con.getAutoCommit());
24
25 try {
26 System.out.println("1. Preparing and executing a unique statement");
27 for (int i = 0; i < 100000; i++) {
28 pstmt = con.prepareStatement("select " + i + ", " + i + " = ?");
29 pstmt.setInt(1, i);
30 ResultSet rs = pstmt.executeQuery();
31 if (rs.next() && i % 1000 == 0) {
32 System.out.println(rs.getInt(1) + ", " + rs.getBoolean(2));
33 }
34 /* this call should cause resources on the server to be
35 * freed */
36 pstmt.close();
37 }
38 } catch (SQLException e) {
39 System.out.println("FAILED :( "+ e.getMessage());
40 System.out.println("ABORTING TEST!!!");
41 }
42
43 con.close();
44 }
45 }