annotate tests/Bug_PrepStmtSetObject_CLOB_6349.java @ 261:d4baf8a4b43a

Update Copyright year to 2019
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 03 Jan 2019 14:43:44 +0100 (2019-01-03)
parents c38d4eaf5479
children 54137aeb1f92
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
1 /*
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
2 * This Source Code Form is subject to the terms of the Mozilla Public
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
5 *
261
d4baf8a4b43a Update Copyright year to 2019
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
7 */
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
8
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
9 import java.sql.*;
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
10
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
11 public class Bug_PrepStmtSetObject_CLOB_6349 {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
12 public static void main(String[] args) throws Exception {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
13 // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
14 Connection con = DriverManager.getConnection(args[0]);
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
15 Statement stmt = con.createStatement();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
16 PreparedStatement pstmt = null;
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
17 ParameterMetaData pmd = null;
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
18 ResultSet rs = null;
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
19 ResultSetMetaData rsmd = null;
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
20
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
21 System.out.println("0. true\t" + con.getAutoCommit());
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
22
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
23 try {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
24 stmt.executeUpdate("CREATE TABLE PrepStmtSetObject_CLOB (myint INT, myvarchar VARCHAR(15), myclob CLOB)");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
25 stmt.executeUpdate("INSERT INTO PrepStmtSetObject_CLOB VALUES (123, 'A string', 'A longer string')");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
26 stmt.executeUpdate("INSERT INTO PrepStmtSetObject_CLOB VALUES (NULL, NULL, NULL)"); // all NULLs
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
27
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
28 pstmt = con.prepareStatement("SELECT myclob, myvarchar, myint FROM PrepStmtSetObject_CLOB WHERE myclob = ?");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
29 pmd = pstmt.getParameterMetaData();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
30 System.out.println("Prepared Query has " + pmd.getParameterCount() + " parameters. Type of first is: " + pmd.getParameterTypeName(1));
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
31 rsmd = pstmt.getMetaData();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
32 System.out.println("Prepared Query has " + rsmd.getColumnCount() + " columns. Type of first is: " + rsmd.getColumnTypeName(1));
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
33
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
34 pstmt.setObject(1, "A longer string");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
35 rs = pstmt.executeQuery();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
36 rsmd = rs.getMetaData();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
37 System.out.println("Query ResultSet has " + rsmd.getColumnCount() + " columns. Type of first is: " + rsmd.getColumnTypeName(1));
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
38
132
ed499bf51b17 Extended test by also querying the prepared query resultset
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 131
diff changeset
39 boolean has_row = rs.next();
ed499bf51b17 Extended test by also querying the prepared query resultset
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 131
diff changeset
40 boolean has_rows = rs.next();
ed499bf51b17 Extended test by also querying the prepared query resultset
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 131
diff changeset
41 if (has_row == false || has_rows == true)
ed499bf51b17 Extended test by also querying the prepared query resultset
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 131
diff changeset
42 System.out.println("Fetching Query ResultSet failed");
ed499bf51b17 Extended test by also querying the prepared query resultset
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 131
diff changeset
43
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
44 stmt.executeUpdate("DROP TABLE PrepStmtSetObject_CLOB");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
45
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
46 } catch (SQLException e) {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
47 System.out.println("FAILED :( "+ e.getMessage());
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
48 while ((e = e.getNextException()) != null)
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
49 System.out.println("FAILED :( " + e.getMessage());
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
50 System.out.println("ABORTING TEST!!!");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
51 } finally {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
52 if (rs != null) rs.close();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
53 if (pstmt != null) pstmt.close();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
54 stmt.close();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
55 }
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
56
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
57 con.close();
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
58 }
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
59 }
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
60