Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/util/Exporter.java @ 943:ff075ed5ce81
Spell check.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Thu, 09 Jan 2025 10:56:14 +0100 (3 months ago) |
parents | d416e9b6b3d0 |
children |
rev | line source |
---|---|
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 /* |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
716
diff
changeset
|
2 * SPDX-License-Identifier: MPL-2.0 |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
716
diff
changeset
|
3 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
4 * This Source Code Form is subject to the terms of the Mozilla Public |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
7 * |
937
d416e9b6b3d0
Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
8 * Copyright 2024, 2025 MonetDB Foundation; |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
716
diff
changeset
|
9 * Copyright August 2008 - 2023 MonetDB B.V.; |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
716
diff
changeset
|
10 * Copyright 1997 - July 2008 CWI. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
11 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
12 |
391
f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
13 package org.monetdb.util; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
14 |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
15 import org.monetdb.jdbc.MonetWrapper; // for dq() and sq() |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
16 |
70
17fbaf2635bb
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
17 import java.io.PrintWriter; |
17fbaf2635bb
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
18 import java.sql.ResultSet; |
17fbaf2635bb
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
19 import java.sql.SQLException; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
20 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
21 public abstract class Exporter { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
22 protected PrintWriter out; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
23 protected boolean useSchema; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
24 |
307
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
25 protected Exporter(final PrintWriter out) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
26 this.out = out; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
27 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
28 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
29 public abstract void dumpSchema( |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
30 final java.sql.DatabaseMetaData dbmd, |
307
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
31 final String type, |
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
32 final String schema, |
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
33 final String name) throws SQLException; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
34 |
307
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
35 public abstract void dumpResultSet(final ResultSet rs) throws SQLException; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
36 |
307
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
37 public abstract void setProperty(final int type, final int value) throws Exception; |
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
38 public abstract int getProperty(final int type) throws Exception; |
70
17fbaf2635bb
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
39 |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
40 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
41 //=== shared utilities |
70
17fbaf2635bb
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
42 |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
43 public final void useSchemas(final boolean use) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
44 useSchema = use; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
45 } |
70
17fbaf2635bb
Expand import java.*.* statements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
46 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
47 /** |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
48 * Convenience function to call the general utility function MonetWrapper.dq() |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
425
diff
changeset
|
49 * to add double quotes around an SQL Identifier such as column or |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
50 * table or schema name in SQL queries. |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
51 * It also adds escapes for special characters: double quotes and the escape character |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
52 * |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
53 * FYI: it is made public as it is also called from client/JdbcClient.java |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
54 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
55 * @param in the string to quote |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 * @return the quoted string |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 */ |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
58 public static final String dq(final String in) { |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
59 return MonetWrapper.dq(in); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
60 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
61 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
62 /** |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
63 * Convenience function to call the general utility function MonetWrapper.sq() |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
64 * to add single quotes around string literals in SQL queries. |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
65 * It also adds escapes for special characters: single quotes and the escape character |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
66 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
67 * @param in the string to quote |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 * @return the quoted string |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
69 */ |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
70 protected static final String sq(final String in) { |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
71 return MonetWrapper.sq(in); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
72 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
73 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
74 /** |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
75 * Simple helper function to repeat a given character a number of times. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
76 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
77 * @param chr the character to repeat |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
78 * @param cnt the number of times to repeat chr |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
79 * @return a String holding cnt times chr |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
80 */ |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
81 protected static final String repeat(final char chr, final int cnt) { |
307
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
82 final char[] buf = new char[cnt]; |
05549bc7ed26
Add "final" keyword to classes, method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
83 java.util.Arrays.fill(buf, chr); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
84 return new String(buf); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
85 } |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
86 |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
87 /** |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
425
diff
changeset
|
88 * Utility method to fetch the "query" column value from sys.tables for a specific view or table in a specific schema |
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
425
diff
changeset
|
89 * The "query" column value contains the original SQL view creation text or the ON clause text when it is a REMOTE TABLE |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
90 * |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
91 * @param con the JDBC connection, may not be null |
943 | 92 * @param schema the schema name, may not be null or empty |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
93 * @param name the view or table name, may not be null or empty |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
94 * @return the value of the "query" field for the specified view/table name and schema. It can return null. |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
95 */ |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
96 protected static final String fetchSysTablesQueryValue( |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
97 final java.sql.Connection con, |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
98 final String schema, |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
99 final String name) |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
100 { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
101 java.sql.Statement stmt = null; |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
102 ResultSet rs = null; |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
103 String val = null; |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
104 try { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
105 stmt = con.createStatement(); |
425
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
106 final String cmd = "SELECT query FROM sys.tables WHERE name = " + sq(name) |
95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
107 + " and schema_id IN (SELECT id FROM sys.schemas WHERE name = " + sq(schema) + ")"; |
318
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
108 rs = stmt.executeQuery(cmd); |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
109 if (rs != null) { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
110 if (rs.next()) { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
111 val = rs.getString(1); |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
112 } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
113 } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
114 } catch (SQLException se) { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
115 /* ignore */ |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
116 } finally { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
117 // free resources |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
118 if (rs != null) { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
119 try { rs.close(); } catch (SQLException se) { /* ignore */ } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
120 } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
121 if (stmt != null) { |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
122 try { stmt.close(); } catch (SQLException se) { /* ignore */ } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
123 } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
124 } |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
125 return val; |
13a9d5316e37
Corrected JdbcClient program: the dumping of a view DDL was incorrect when the view creation statement was not starting with "create view ", such as when it was created using "CREATE VIEW" or "create or replace view".
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
315
diff
changeset
|
126 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
127 } |