annotate tests/Bug_Connect_as_voc_getMetaData_Failure_Bug_6388.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
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
1 /*
8b40a845240c Added test program for Bug 6388
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
8b40a845240c Added test program for Bug 6388
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
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8b40a845240c Added test program for Bug 6388
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.
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
7 */
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
8
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
9 import java.sql.*;
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
10
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
11 public class Bug_Connect_as_voc_getMetaData_Failure_Bug_6388 {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
12 public static void main(String[] args) throws SQLException
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
13 {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
14 Connection con1 = null;
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
15 Statement stmt1 = null;
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
16
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
17 // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
18 con1 = DriverManager.getConnection(args[0]);
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
19 stmt1 = con1.createStatement();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
20
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
21 // test the creation of a table with concurrent clients
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
22 try {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
23 System.out.println("1. CREATE USER voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
24 stmt1.executeUpdate("CREATE USER \"voc\" WITH PASSWORD 'voc' NAME 'VOC Explorer' SCHEMA \"sys\"");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
25 System.out.println("2. CREATE SCHEMA voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
26 stmt1.executeUpdate("CREATE SCHEMA \"voc\" AUTHORIZATION \"voc\"");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
27 System.out.println("3. ALTER USER voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
28 stmt1.executeUpdate("ALTER USER \"voc\" SET SCHEMA \"voc\"");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
29 System.out.println("creation succeeded :)");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
30 System.out.println();
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
31
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
32 login_as_voc_and_get_MetaData(args[0].replace("=monetdb", "=voc"));
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
33
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
34 System.out.println();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
35 System.out.println("Cleanup created objects");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
36 System.out.println("5. ALTER USER voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
37 stmt1.executeUpdate("ALTER USER \"voc\" SET SCHEMA \"sys\"");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
38 System.out.println("6. DROP SCHEMA voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
39 stmt1.executeUpdate("DROP SCHEMA \"voc\"");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
40 System.out.println("7. DROP USER voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
41 stmt1.executeUpdate("DROP USER \"voc\"");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
42 System.out.println("cleanup succeeded :)");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
43 } catch (SQLException e) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
44 System.out.println("FAILED creating user and schema voc. " + e.getMessage());
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
45 } finally {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
46 stmt1.close();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
47 con1.close();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
48 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
49 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
50
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
51 private static void login_as_voc_and_get_MetaData(String connectString) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
52 Connection con2 = null;
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
53
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
54 try {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
55 System.out.println("4.1. connect as user: voc");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
56 con2 = DriverManager.getConnection(connectString);
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
57 System.out.println("connected :)");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
58 } catch (SQLException e) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
59 System.out.println("FAILED to connect as user voc. " + e.getMessage());
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
60 return;
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
61 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
62
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
63 try {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
64 DatabaseMetaData dbmd = con2.getMetaData();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
65
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
66 System.out.println("4.2. getUserName()");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
67 System.out.println("UserName = " + dbmd.getUserName());
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
68
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
69 System.out.println("4.3. getMaxConnections()");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
70 System.out.println("MaxConnections = " + dbmd.getMaxConnections());
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
71
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
72 System.out.println("4.4. getDatabaseProductVersion()");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
73 String dbmsVersion = dbmd.getDatabaseProductVersion(); // should be 11.27.1 or higher
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
74 boolean postJul2017 = ("11.27.1".compareTo(dbmsVersion) <= 0);
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
75 System.out.println("DatabaseProductVersion = " + (postJul2017 ? "11.27.+" : dbmsVersion));
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
76
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
77 System.out.println("4.5. getDatabaseMajorVersion()");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
78 System.out.println("DatabaseMajorVersion = " + dbmd.getDatabaseMajorVersion()); // should be 11
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
79
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
80 System.out.println("4.6. getDatabaseMinorVersion()");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
81 int dbmsMinorVersion = dbmd.getDatabaseMinorVersion(); // should be 27 or higher
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
82 System.out.println("DatabaseMinorVersion = " + (dbmsMinorVersion >= 27 ? "27+" : dbmsMinorVersion));
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
83
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
84 System.out.println("4.7. getTables(null, 'tmp', null, null)");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
85 ResultSet rs1 = dbmd.getTables(null, "tmp", null, null);
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
86 if (rs1 != null) {
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
87 System.out.println("List Tables in schema tmp:");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
88 while (rs1.next()) {
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
89 System.out.println(rs1.getString(3));
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
90 }
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
91 rs1.close();
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
92 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
93 System.out.println("completed listing Tables in schema tmp");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
94
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
95 System.out.println("4.8. getTableTypes()");
148
db5fa40cfa31 Update program to list the productversion only when it is lower than 11.27.1
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 146
diff changeset
96 rs1 = dbmd.getTableTypes();
146
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
97 if (rs1 != null) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
98 System.out.println("List TableTypes:");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
99 while (rs1.next()) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
100 System.out.println(rs1.getString(1));
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
101 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
102 rs1.close();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
103 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
104 System.out.println("completed listing TableTypes");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
105
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
106 System.out.println("voc meta data Test completed successfully");
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
107 } catch (SQLException e) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
108 System.out.println("FAILED fetching MonetDatabaseMetaData. " + e.getMessage());
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
109 } finally {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
110 try {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
111 con2.close();
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
112 } catch (SQLException e) {
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
113 System.out.println("FAILED to close voc connection. " + e.getMessage());
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
114 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
115 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
116 }
8b40a845240c Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
117 }