Mercurial > hg > monetdb-java
annotate tests/Bug_Connect_as_voc_getMetaData_Failure_Bug_6388.java @ 391:f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
This naming complies to the Java Package Naming convention as MonetDB's main website is www.monetdb.org.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 12 Nov 2020 22:02:01 +0100 (2020-11-12) |
parents | 54137aeb1f92 |
children | bf9f6b6ecf40 |
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 * |
350
54137aeb1f92
Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2020 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 con1 = DriverManager.getConnection(args[0]); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
18 stmt1 = con1.createStatement(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
19 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
20 // 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
|
21 try { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
22 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 System.out.println(); |
146
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
30 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
31 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
|
32 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
33 System.out.println(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
34 System.out.println("Cleanup created objects"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 stmt1.executeUpdate("DROP SCHEMA \"voc\""); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
39 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
|
40 stmt1.executeUpdate("DROP USER \"voc\""); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
41 System.out.println("cleanup succeeded :)"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
42 } catch (SQLException e) { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
43 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
|
44 } finally { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
45 stmt1.close(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
46 con1.close(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
47 } |
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 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
|
51 Connection con2 = null; |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
52 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
53 try { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
54 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
|
55 con2 = DriverManager.getConnection(connectString); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
56 System.out.println("connected :)"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
57 } catch (SQLException e) { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
58 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
|
59 return; |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
60 } |
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 try { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
63 DatabaseMetaData dbmd = con2.getMetaData(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
64 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
65 System.out.println("4.2. getUserName()"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
66 System.out.println("UserName = " + dbmd.getUserName()); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
67 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
68 System.out.println("4.3. getMaxConnections()"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
69 System.out.println("MaxConnections = " + dbmd.getMaxConnections()); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
70 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 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
|
75 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
76 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
|
77 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
|
78 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
83 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
|
84 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
|
85 if (rs1 != null) { |
146
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 } |
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
|
90 rs1.close(); |
146
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
91 } |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
92 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
|
93 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
94 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
|
95 rs1 = dbmd.getTableTypes(); |
146
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
96 if (rs1 != null) { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
97 System.out.println("List TableTypes:"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
98 while (rs1.next()) { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
99 System.out.println(rs1.getString(1)); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
100 } |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
101 rs1.close(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
102 } |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
103 System.out.println("completed listing TableTypes"); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
104 |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
105 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
|
106 } catch (SQLException e) { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
107 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
|
108 } finally { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
109 try { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
110 con2.close(); |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
111 } catch (SQLException e) { |
8b40a845240c
Added test program for Bug 6388
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
112 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
|
113 } |
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 } |