Mercurial > hg > monetdb-java
comparison tests/Test_Smoreresults.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 | |
11 public class Test_Smoreresults { | |
12 public static void main(String[] args) throws Exception { | |
13 Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); | |
14 Connection con = DriverManager.getConnection(args[0]); | |
15 Statement stmt = con.createStatement(); | |
16 ResultSet rs = null; | |
17 //DatabaseMetaData dbmd = con.getMetaData(); | |
18 | |
19 // >> true: auto commit should be on by default | |
20 System.out.println("0. true\t" + con.getAutoCommit()); | |
21 | |
22 try { | |
23 System.out.print("1. more results?..."); | |
24 if (stmt.getMoreResults() != false || stmt.getUpdateCount() != -1) | |
25 throw new SQLException("more results on an unitialised Statement, how can that be?"); | |
26 System.out.println(" nope :)"); | |
27 | |
28 System.out.print("2. SELECT 1..."); | |
29 if (stmt.execute("SELECT 1;") == false) | |
30 throw new SQLException("SELECT 1 returns update or no results"); | |
31 System.out.println(" ResultSet :)"); | |
32 | |
33 System.out.print("3. more results?..."); | |
34 if (stmt.getMoreResults() != false || stmt.getUpdateCount() != -1) | |
35 throw new SQLException("more results after SELECT 1 query, how can that be?"); | |
36 System.out.println(" nope :)"); | |
37 | |
38 System.out.print("4. even more results?..."); | |
39 if (stmt.getMoreResults() != false || stmt.getUpdateCount() != -1) | |
40 throw new SQLException("more results after SELECT 1 query, how can that be?"); | |
41 System.out.println(" nope :)"); | |
42 | |
43 } catch (SQLException e) { | |
44 // this means we failed (table not there perhaps?) | |
45 System.out.println("FAILED :( " + e.getMessage()); | |
46 System.out.println("ABORTING TEST!!!"); | |
47 } | |
48 | |
49 if (rs != null) rs.close(); | |
50 | |
51 con.close(); | |
52 } | |
53 } |