Mercurial > hg > monetdb-java
annotate tests/BugResultSetMetaData_Bug_6183.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 |
---|---|
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
1 /* |
839ffec1d36d
Fix for bug 6183.
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 |
839ffec1d36d
Fix for bug 6183.
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 |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
839ffec1d36d
Fix for bug 6183.
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. |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
7 */ |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
8 |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
9 import java.sql.*; |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
10 |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
11 public class BugResultSetMetaData_Bug_6183 { |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
12 static final String dqTblName = "\"my dq_table\""; |
121
65b27b29ca71
Extending test with 3 additional columns.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
119
diff
changeset
|
13 static final String[] dqColNames = { "\"my space\"", "\"my, comma_space\"", "\"my$dollar\"", "\"my#hash\"", "\"my tab\"" |
256
37b537a7ad60
Use column names that are actually standard SQL.
Sjoerd Mullender <sjoerd@acm.org>
parents:
200
diff
changeset
|
14 , "\"my ,tab_comma\"", "\"my, comma_tab\"", "\"my\"\"double_doublequote\"", "\"Abc\"", "\" \"", "\"123\"" }; |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
15 |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
16 public static void main(String[] args) throws Exception { |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
17 Connection con = DriverManager.getConnection(args[0]); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
18 Statement stmt = con.createStatement(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
19 ResultSet rs = null; |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
20 try { |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
21 System.out.println("1. create table " + dqTblName); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
22 StringBuilder sb = new StringBuilder(30 + (dqColNames.length * (30 + 15))); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
23 sb.append("CREATE TABLE ").append(dqTblName).append(" ("); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
24 for (int n = 0; n < dqColNames.length; n++) { |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
25 sb.append(dqColNames[n]); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
26 sb.append(" varchar(").append(31 + n).append(')'); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
27 if (n < (dqColNames.length -1)) |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
28 sb.append(", "); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
29 } |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
30 sb.append(')'); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
31 int ret = stmt.executeUpdate(sb.toString()); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
32 System.out.println(" returned: " + ret + " (expected -2)"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
33 System.out.println(); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
34 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
35 String tblName = dqTblName.substring(1, dqTblName.length() -1); // trim the leading and trailing double quote characters |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
36 System.out.println("2. show column names of this new table (" + tblName + ") via sys.columns query"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
37 rs = stmt.executeQuery("SELECT number, name, type from sys.columns where table_id in (select id from sys._tables where name = '" + tblName + "') order by number"); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
38 showResultAndClose(rs); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
39 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
40 System.out.println("3. insert 1 row of data with values same as column names"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
41 sb.setLength(0); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
42 sb.append("INSERT INTO ").append(dqTblName).append(" VALUES ("); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
43 for (int n = 0; n < dqColNames.length; n++) { |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
44 sb.append('\''); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
45 sb.append(dqColNames[n]); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
46 sb.append('\''); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
47 if (n < (dqColNames.length -1)) |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
48 sb.append(", "); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
49 } |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
50 sb.append(')'); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
51 ret = stmt.executeUpdate(sb.toString()); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
52 System.out.println(" returned: " + ret + " (expected 1)"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
53 System.out.println(); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
54 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
55 System.out.println("4. insert 1 row of data with values same as column names but without enclosing double quotes"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
56 sb.setLength(0); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
57 sb.append("INSERT INTO ").append(dqTblName).append(" VALUES ("); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
58 for (int n = 0; n < dqColNames.length; n++) { |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
59 sb.append('\''); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
60 // remove enclosing double quotes |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
61 sb.append(dqColNames[n].substring(1, dqColNames[n].length() -1)); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
62 sb.append('\''); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
63 if (n < (dqColNames.length -1)) |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
64 sb.append(", "); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
65 } |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
66 sb.append(')'); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
67 ret = stmt.executeUpdate(sb.toString()); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
68 System.out.println(" returned: " + ret + " (expected 1)"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
69 System.out.println(); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
70 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
71 // query each column separately |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
72 for (int n = 0; n < dqColNames.length; n++) { |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
73 executeQueryAndShowResult(stmt, dqColNames[n], 5 + n); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
74 } |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
75 // query all columns |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
76 executeQueryAndShowResult(stmt, "*", 5 + dqColNames.length); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
77 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
78 System.out.println("Finally drop table " + dqTblName); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
79 ret = stmt.executeUpdate("DROP TABLE " + dqTblName); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
80 System.out.println(" returned: " + ret + " (expected -2)"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
81 System.out.println(); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
82 } catch (SQLException se) { |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
83 System.out.println("Failure occurred: " + se); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
84 } finally { |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
85 if (rs != null) |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
86 rs.close(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
87 stmt.close(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
88 } |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
89 con.close(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
90 } |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
91 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
92 private static void executeQueryAndShowResult(Statement st, String col_list, int query_count) throws SQLException { |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
93 System.out.print(query_count); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
94 System.out.println(". show content of column(s): " + col_list); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
95 ResultSet rs = st.executeQuery("SELECT " + col_list + " from " + dqTblName); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
96 showResultAndClose(rs); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
97 } |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
98 |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
99 private static void showResultAndClose(ResultSet rs) throws SQLException { |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
100 ResultSetMetaData rsmd = rs.getMetaData(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
101 int rs_col_count = rsmd.getColumnCount(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
102 System.out.println("Resultset with " + rs_col_count + " columns"); |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
103 System.out.println("\tColumn Name, Column Label:"); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
104 for (int col = 1; col <= rs_col_count; col++) { |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
105 System.out.println(col + "\t" + rsmd.getColumnName(col) + "\t" +rsmd.getColumnLabel(col)); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
106 } |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
107 |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
108 System.out.println("Data rows:"); |
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
109 long row_count = 0; |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
110 while (rs.next()) { |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
111 row_count++; |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
112 for (int col = 1; col <= rs_col_count; col++) { |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
113 if (col > 1) |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
114 System.out.print("\t"); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
115 System.out.print(rs.getString(col)); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
116 } |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
117 System.out.println(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
118 } |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
119 rs.close(); |
119
1ea2ee3b946c
Extend HeaderLineParser to also correctly parse result set header lines for table
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
104
diff
changeset
|
120 System.out.println("Listed " + row_count + " rows"); |
104
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
121 System.out.println(); |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
122 } |
839ffec1d36d
Fix for bug 6183.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
123 } |