Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetResultSetMetaData.java @ 718:7138bbc6952e
Do not make this class public as it is to be used only within this package.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 19 Jan 2023 16:34:26 +0100 (2023-01-19) |
parents | 7240d2dd369f |
children | 99baab703566 |
rev | line source |
---|---|
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
1 /* |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
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 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
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 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
5 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
7 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
8 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
9 package org.monetdb.jdbc; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
10 |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
713
diff
changeset
|
11 import java.sql.ResultSetMetaData; |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
12 import java.sql.SQLException; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
13 import java.sql.Types; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
14 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
15 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
16 *<pre> |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
17 * A {@link ResultSetMetaData} suitable for the MonetDB database. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
18 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
19 * An object that can be used to get information about the types and |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
20 * properties of the columns in a ResultSet object. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
21 *</pre> |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
22 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
23 * @author Martin van Dinther |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
24 * @version 1.0 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
25 */ |
718
7138bbc6952e
Do not make this class public as it is to be used only within this package.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
26 final class MonetResultSetMetaData |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
27 extends MonetWrapper |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
28 implements ResultSetMetaData |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
29 { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
30 /** The parental Connection object */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
31 private final MonetConnection conn; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
32 |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
33 /** The number of columns, it can be zero !! */ |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
34 private final int colCount; |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
35 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
36 /** The schema names of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
37 private final String[] schemas; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
38 /** The table names of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
39 private final String[] tables; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
40 /** The names of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
41 private final String[] columns; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
42 /** The MonetDB type names of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
43 private final String[] types; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
44 /** The JDBC SQL type codes of the columns in this ResultSet. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
45 * The content will be derived once from the MonetDB String[] types */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
46 private final int[] JdbcSQLTypes; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
47 /** The lengths of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
48 private final int[] lengths; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
49 /** The precisions of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
50 private final int[] precisions; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
51 /** The scales of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
52 private final int[] scales; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
53 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
54 /* For the methods: isNullable() and isAutoIncrement(), we need to query the server. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
55 * To do this efficiently we query many columns combined in one SELECT |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
56 * query and cache the results in following arrays. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
57 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
58 private final int array_size; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
59 /** Whether info for a column is already queried or not */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
60 private final boolean[] _is_queried; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
61 /** Whether info for a column is already fetched or not */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
62 private final boolean[] _is_fetched; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
63 /** The nullability of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
64 private final int[] _isNullable; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
65 /** The auto increment property of the columns in this ResultSet */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
66 private final boolean[] _isAutoincrement; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
67 /** an upper bound value to calculate the range of columns to query */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
68 private int nextUpperbound; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
69 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
70 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
71 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
72 * Main constructor backed by the given connection and header. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
73 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
74 * @param connection the parent connection |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
75 * @param header a ResultSetResponse containing the metadata |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
76 * @throws IllegalArgumentException if called with null for one of the arguments |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
77 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
78 MonetResultSetMetaData( |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
79 final MonetConnection connection, |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
80 final MonetConnection.ResultSetResponse header) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
81 throws IllegalArgumentException |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
82 { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
83 if (connection == null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
84 throw new IllegalArgumentException("Connection may not be null!"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
85 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
86 if (header == null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
87 throw new IllegalArgumentException("Header may not be null!"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
88 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
89 this.conn = connection; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
90 schemas = header.getSchemaNames(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
91 tables = header.getTableNames(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
92 columns = header.getNames(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
93 lengths = header.getColumnLengths(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
94 types = header.getTypes(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
95 precisions = header.getColumnPrecisions(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
96 scales = header.getColumnScales(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
97 |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
98 colCount = columns.length; |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
99 if (columns.length != tables.length || columns.length != types.length ) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
100 throw new IllegalArgumentException("Inconsistent Header metadata"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
101 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
102 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
103 // derive the JDBC SQL type codes from the types[] names once |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
104 JdbcSQLTypes = new int[types.length]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
105 for (int i = 0; i < types.length; i++) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
106 int javaSQLtype = MonetDriver.getJdbcSQLType(types[i]); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
107 if (javaSQLtype == Types.CLOB) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
108 if (connection.mapClobAsVarChar()) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
109 javaSQLtype = Types.VARCHAR; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
110 } else |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
111 if (javaSQLtype == Types.BLOB) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
112 if (connection.mapBlobAsVarBinary()) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
113 javaSQLtype = Types.VARBINARY; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
114 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
115 JdbcSQLTypes[i] = javaSQLtype; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
116 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
117 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
118 // initialize structures for storing columns info on nullability and autoincrement |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
119 array_size = colCount + 1; // add 1 as in JDBC columns start from 1 (array from 0). |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
120 _is_queried = new boolean[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
121 _is_fetched = new boolean[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
122 _isNullable = new int[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
123 _isAutoincrement = new boolean[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
124 nextUpperbound = array_size; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
125 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
126 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
127 /** |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
128 * Alternative constructor backed by the given connection and metadata arrays. |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
129 * It is used by MonetPreparedStatement. |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
130 * |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
131 * @param connection the parent connection |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
132 * @param colCount the number of result columns, it can be zero !! |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
133 * @param schemas the schema names |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
134 * @param tables the table names |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
135 * @param columns the column names |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
136 * @param types the MonetDB type names |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
137 * @param jdbcTypes the JDBC SQL type codes |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
138 * @param lengths the maximum display length for each column |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
139 * @param precisions the precision for each column |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
140 * @param scales the scale for each column |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
141 * @throws IllegalArgumentException if called with null for one of the arguments |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
142 */ |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
143 MonetResultSetMetaData( |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
144 final MonetConnection connection, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
145 final int colcount, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
146 final String[] schemas, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
147 final String[] tables, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
148 final String[] columns, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
149 final String[] types, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
150 final int[] jdbcTypes, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
151 final int[] lengths, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
152 final int[] precisions, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
153 final int[] scales) |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
154 throws IllegalArgumentException |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
155 { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
156 if (connection == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
157 throw new IllegalArgumentException("Connection may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
158 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
159 if (schemas == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
160 throw new IllegalArgumentException("Schemas may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
161 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
162 if (tables == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
163 throw new IllegalArgumentException("Tables may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
164 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
165 if (columns == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
166 throw new IllegalArgumentException("Columns may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
167 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
168 if (types == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
169 throw new IllegalArgumentException("MonetDB Types may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
170 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
171 if (jdbcTypes == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
172 throw new IllegalArgumentException("JDBC Types may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
173 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
174 if (lengths == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
175 throw new IllegalArgumentException("Lengths may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
176 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
177 if (precisions == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
178 throw new IllegalArgumentException("Precisions may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
179 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
180 if (scales == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
181 throw new IllegalArgumentException("Scales may not be null!"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
182 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
183 if (columns.length != tables.length || columns.length != types.length ) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
184 throw new IllegalArgumentException("Inconsistent Header metadata"); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
185 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
186 this.conn = connection; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
187 this.colCount = colcount; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
188 this.schemas = schemas; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
189 this.tables = tables; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
190 this.columns = columns; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
191 this.lengths = lengths; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
192 this.types = types; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
193 this.JdbcSQLTypes = jdbcTypes; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
194 this.precisions = precisions; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
195 this.scales = scales; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
196 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
197 // initialize structures for storing columns info on nullability and autoincrement |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
198 array_size = colCount + 1; // add 1 as in JDBC columns start from 1 (array from 0). |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
199 _is_queried = new boolean[array_size]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
200 _is_fetched = new boolean[array_size]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
201 _isNullable = new int[array_size]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
202 _isAutoincrement = new boolean[array_size]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
203 nextUpperbound = array_size; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
204 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
205 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
206 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
207 * Returns the number of columns in this ResultSet object. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
208 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
209 * @return the number of columns |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
210 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
211 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
212 public int getColumnCount() { |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
213 // for debug: System.out.println("In rsmd.getColumnCount() = " + colCount + ". this rsmd object = " + this.toString()); |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
214 return colCount; |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
215 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
216 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
217 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
218 * Indicates whether the designated column is automatically numbered. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
219 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
220 * This method is currently very expensive for BIGINT, |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
221 * INTEGER, SMALLINT and TINYINT result column types |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
222 * as it needs to retrieve the information from the |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
223 * database using an SQL meta data query. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
224 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
225 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
226 * @return true if so; false otherwise |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
227 * @throws SQLException if there is no such column or a database access error occurs |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
228 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
229 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
230 public boolean isAutoIncrement(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
231 // only few integer types can be auto incrementable in MonetDB |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
232 // see: https://www.monetdb.org/Documentation/SQLReference/DataTypes/SerialDatatypes |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
233 switch (getColumnType(column)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
234 case Types.BIGINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
235 case Types.INTEGER: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
236 case Types.SMALLINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
237 case Types.TINYINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
238 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
239 if (_is_fetched[column] != true) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
240 fetchColumnInfo(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
241 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
242 return _isAutoincrement[column]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
243 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
244 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
245 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
246 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
247 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
248 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
249 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
250 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
251 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
252 * Indicates whether a column's case matters. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
253 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
254 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
255 * @return true for all character string columns else false |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
256 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
257 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
258 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
259 public boolean isCaseSensitive(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
260 switch (getColumnType(column)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
261 case Types.CHAR: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
262 case Types.LONGVARCHAR: // MonetDB doesn't use type LONGVARCHAR, it's here for completeness |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
263 case Types.CLOB: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
264 return true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
265 case Types.VARCHAR: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
266 final String monettype = getColumnTypeName(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
267 if (monettype != null && monettype.length() == 4) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
268 // data of type inet or uuid is not case sensitive |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
269 if ("inet".equals(monettype) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
270 || "uuid".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
271 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
272 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
273 return true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
274 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
275 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
276 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
277 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
278 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
279 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
280 * Indicates whether the designated column can be used in a |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
281 * where clause. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
282 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
283 * Returning true for all here, even for CLOB, BLOB. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
284 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
285 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
286 * @return true |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
287 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
288 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
289 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
290 public boolean isSearchable(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
291 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
292 return true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
293 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
294 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
295 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
296 * Indicates whether the designated column is a cash value. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
297 * From the MonetDB database perspective it is by definition |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
298 * unknown whether the value is a currency, because there are |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
299 * no currency datatypes such as MONEY. With this knowledge |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
300 * we can always return false here. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
301 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
302 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
303 * @return false |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
304 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
305 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
306 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
307 public boolean isCurrency(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
308 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
309 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
310 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
311 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
312 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
313 * Indicates the nullability of values in the designated column. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
314 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
315 * This method is currently very expensive as it needs to |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
316 * retrieve the information from the database using an SQL |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
317 * meta data query. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
318 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
319 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
320 * @return the nullability status of the given column; one of |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
321 * columnNoNulls, columnNullable or columnNullableUnknown |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
322 * @throws SQLException if there is no such column or a database access error occurs |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
323 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
324 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
325 public int isNullable(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
326 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
327 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
328 if (_is_fetched[column] != true) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
329 fetchColumnInfo(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
330 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
331 return _isNullable[column]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
332 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
333 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
334 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
335 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
336 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
337 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
338 * Indicates whether values in the designated column are signed |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
339 * numbers. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
340 * Within MonetDB all numeric types (except oid and ptr) are signed. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
341 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
342 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
343 * @return true if so; false otherwise |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
344 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
345 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
346 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
347 public boolean isSigned(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
348 // we can hardcode this, based on the colum type |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
349 switch (getColumnType(column)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
350 case Types.TINYINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
351 case Types.SMALLINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
352 case Types.INTEGER: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
353 case Types.REAL: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
354 case Types.FLOAT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
355 case Types.DOUBLE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
356 case Types.DECIMAL: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
357 case Types.NUMERIC: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
358 return true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
359 case Types.BIGINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
360 final String monettype = getColumnTypeName(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
361 if (monettype != null && monettype.length() == 3) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
362 // data of type oid or ptr is not signed |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
363 if ("oid".equals(monettype) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
364 || "ptr".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
365 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
366 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
367 return true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
368 // All other types should return false |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
369 // case Types.BOOLEAN: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
370 // case Types.DATE: // can year be negative? |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
371 // case Types.TIME: // can time be negative? |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
372 // case Types.TIME_WITH_TIMEZONE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
373 // case Types.TIMESTAMP: // can year be negative? |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
374 // case Types.TIMESTAMP_WITH_TIMEZONE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
375 default: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
376 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
377 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
378 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
379 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
380 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
381 * Indicates the designated column's normal maximum width in |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
382 * characters. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
383 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
384 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
385 * @return the normal maximum number of characters allowed as the |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
386 * width of the designated column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
387 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
388 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
389 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
390 public int getColumnDisplaySize(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
391 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
392 if (lengths != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
393 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
394 return lengths[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
395 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
396 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
397 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
398 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
399 return 1; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
400 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
401 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
402 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
403 * Gets the designated column's suggested title for use in |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
404 * printouts and displays. The suggested title is usually |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
405 * specified by the SQL AS clause. If a SQL AS is not specified, |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
406 * the value returned from getColumnLabel will be the same as |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
407 * the value returned by the getColumnName method. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
408 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
409 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
410 * @return the suggested column title |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
411 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
412 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
413 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
414 public String getColumnLabel(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
415 return getColumnName(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
416 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
417 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
418 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
419 * Gets the designated column's name |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
420 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
421 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
422 * @return the column name |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
423 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
424 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
425 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
426 public String getColumnName(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
427 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
428 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
429 return columns[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
430 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
431 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
432 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
433 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
434 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
435 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
436 * Gets the designated column's table's catalog name. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
437 * MonetDB does not support the catalog naming concept as in: catalog.schema.table naming scheme |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
438 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
439 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
440 * @return null or the name of the catalog for the table in which the given |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
441 * column appears or "" if not applicable |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
442 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
443 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
444 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
445 public String getCatalogName(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
446 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
447 return null; // MonetDB does NOT support catalog qualifiers |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
448 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
449 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
450 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
451 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
452 * Get the designated column's schema name. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
453 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
454 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
455 * @return schema name or "" if not applicable |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
456 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
457 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
458 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
459 public String getSchemaName(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
460 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
461 if (schemas != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
462 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
463 return schemas[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
464 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
465 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
466 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
467 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
468 return ""; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
469 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
470 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
471 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
472 * Gets the designated column's table name. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
473 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
474 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
475 * @return table name or "" if not applicable |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
476 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
477 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
478 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
479 public String getTableName(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
480 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
481 if (tables != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
482 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
483 return tables[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
484 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
485 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
486 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
487 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
488 return ""; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
489 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
490 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
491 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
492 * Retrieves the designated column's SQL type. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
493 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
494 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
495 * @return SQL type from java.sql.Types |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
496 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
497 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
498 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
499 public int getColumnType(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
500 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
501 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
502 return JdbcSQLTypes[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
503 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
504 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
505 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
506 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
507 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
508 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
509 * Retrieves the designated column's database-specific type name. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
510 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
511 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
512 * @return type name used by the database. If the column type is a |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
513 * user-defined type, then a fully-qualified type name is |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
514 * returned. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
515 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
516 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
517 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
518 public String getColumnTypeName(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
519 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
520 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
521 final String monettype = types[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
522 if (monettype.endsWith("_interval")) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
523 /* convert the interval type names to valid SQL data type names, |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
524 * such that generic applications can use them in create table statements |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
525 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
526 if ("day_interval".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
527 return "interval day"; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
528 if ("month_interval".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
529 return "interval month"; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
530 if ("sec_interval".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
531 return "interval second"; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
532 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
533 return monettype; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
534 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
535 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
536 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
537 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
538 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
539 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
540 * Get the designated column's specified column size. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
541 * For numeric data, this is the maximum precision. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
542 * For character data, this is the length in characters. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
543 * For datetime datatypes, this is the length in characters |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
544 * of the String representation (assuming the maximum |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
545 * allowed precision of the fractional seconds component). |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
546 * For binary data, this is the length in bytes. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
547 * For the ROWID datatype, this is the length in bytes. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
548 * 0 is returned for data types where the column size is not applicable. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
549 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
550 * @param column the first column is 1, the second is 2, ... |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
551 * @return maximum precision or length in characters |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
552 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
553 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
554 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
555 public int getPrecision(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
556 switch (getColumnType(column)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
557 case Types.BIGINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
558 return 19; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
559 case Types.INTEGER: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
560 return 10; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
561 case Types.SMALLINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
562 return 5; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
563 case Types.TINYINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
564 return 3; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
565 case Types.REAL: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
566 return 7; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
567 case Types.FLOAT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
568 case Types.DOUBLE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
569 return 15; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
570 case Types.DECIMAL: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
571 case Types.NUMERIC: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
572 // these data types have a variable precision (max precision is 38) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
573 if (precisions != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
574 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
575 return precisions[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
576 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
577 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
578 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
579 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
580 return 18; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
581 case Types.CHAR: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
582 case Types.VARCHAR: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
583 case Types.LONGVARCHAR: // MonetDB doesn't use type LONGVARCHAR, it's here for completeness |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
584 case Types.CLOB: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
585 // these data types have a variable length |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
586 if (precisions != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
587 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
588 int prec = precisions[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
589 if (prec <= 0) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
590 // apparently no positive precision or max length could be fetched |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
591 // use columnDisplaySize() value as fallback |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
592 prec = getColumnDisplaySize(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
593 precisions[column - 1] = prec; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
594 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
595 return prec; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
596 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
597 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
598 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
599 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
600 // apparently no precisions array is available |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
601 // use columnDisplaySize() value as alternative |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
602 return getColumnDisplaySize(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
603 case Types.BINARY: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
604 case Types.VARBINARY: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
605 case Types.BLOB: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
606 // these data types have a variable length |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
607 if (precisions != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
608 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
609 int prec = precisions[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
610 if (prec <= 0) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
611 // apparently no positive precision or max length could be fetched |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
612 // use columnDisplaySize() value as fallback |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
613 // It expect number of bytes, not number of hex chars |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
614 prec = (getColumnDisplaySize(column) / 2) +1; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
615 precisions[column - 1] = prec; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
616 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
617 return prec; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
618 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
619 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
620 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
621 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
622 // apparently no precisions array is available |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
623 // use columnDisplaySize() value as alternative |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
624 // It expect number of bytes, not number of hex chars |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
625 return (getColumnDisplaySize(column) / 2) +1; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
626 case Types.DATE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
627 return 10; // 2020-10-08 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
628 case Types.TIME: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
629 return 15; // 21:51:34.399753 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
630 case Types.TIME_WITH_TIMEZONE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
631 return 21; // 21:51:34.399753+02:00 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
632 case Types.TIMESTAMP: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
633 return 26; // 2020-10-08 21:51:34.399753 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
634 case Types.TIMESTAMP_WITH_TIMEZONE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
635 return 32; // 2020-10-08 21:51:34.399753+02:00 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
636 case Types.BOOLEAN: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
637 return 1; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
638 default: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
639 // All other types should return 0 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
640 return 0; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
641 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
642 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
643 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
644 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
645 * Gets the designated column's number of digits to right of |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
646 * the decimal point. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
647 * 0 is returned for data types where the scale is not applicable. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
648 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
649 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
650 * @return scale |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
651 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
652 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
653 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
654 public int getScale(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
655 switch (getColumnType(column)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
656 case Types.DECIMAL: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
657 case Types.NUMERIC: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
658 { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
659 // these data types may have a variable scale, max scale is 38 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
660 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
661 // Special handling for: day_interval and sec_interval as they are |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
662 // mapped to Types.NUMERIC and Types.DECIMAL types (see MonetDriver typeMap) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
663 // They appear to have a fixed scale (tested against Oct2020) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
664 final String monettype = getColumnTypeName(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
665 if ("interval day".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
666 return 0; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
667 if ("interval second".equals(monettype)) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
668 return 3; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
669 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
670 if (scales != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
671 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
672 return scales[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
673 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
674 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
675 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
676 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
677 return 0; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
678 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
679 case Types.TIME: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
680 case Types.TIME_WITH_TIMEZONE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
681 case Types.TIMESTAMP: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
682 case Types.TIMESTAMP_WITH_TIMEZONE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
683 if (scales != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
684 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
685 return scales[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
686 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
687 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
688 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
689 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
690 // support microseconds, so scale 6 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
691 return 6; // 21:51:34.399753 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
692 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
693 // All other types should return 0 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
694 // case Types.BIGINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
695 // case Types.INTEGER: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
696 // case Types.SMALLINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
697 // case Types.TINYINT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
698 // case Types.REAL: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
699 // case Types.FLOAT: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
700 // case Types.DOUBLE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
701 // case Types.CHAR: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
702 // case Types.VARCHAR: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
703 // case Types.LONGVARCHAR: // MonetDB doesn't use type LONGVARCHAR, it's here for completeness |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
704 // case Types.CLOB: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
705 // case Types.BINARY: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
706 // case Types.VARBINARY: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
707 // case Types.BLOB: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
708 // case Types.DATE: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
709 // case Types.BOOLEAN: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
710 default: |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
711 return 0; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
712 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
713 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
714 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
715 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
716 * Indicates whether the designated column is definitely not |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
717 * writable. MonetDB does not support cursor updates, so |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
718 * nothing is writable. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
719 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
720 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
721 * @return true if so; false otherwise |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
722 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
723 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
724 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
725 public boolean isReadOnly(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
726 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
727 return true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
728 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
729 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
730 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
731 * Indicates whether it is possible for a write on the |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
732 * designated column to succeed. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
733 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
734 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
735 * @return true if so; false otherwise |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
736 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
737 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
738 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
739 public boolean isWritable(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
740 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
741 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
742 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
743 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
744 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
745 * Indicates whether a write on the designated column will |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
746 * definitely succeed. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
747 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
748 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
749 * @return true if so; false otherwise |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
750 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
751 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
752 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
753 public boolean isDefinitelyWritable(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
754 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
755 return false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
756 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
757 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
758 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
759 * Returns the fully-qualified name of the Java class whose instances |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
760 * are manufactured if the method ResultSet.getObject is called to |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
761 * retrieve a value from the column. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
762 * ResultSet.getObject may return a subclass of the class returned by |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
763 * this method. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
764 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
765 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
766 * @return the fully-qualified name of the class in the Java programming |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
767 * language that would be used by the method ResultSet.getObject |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
768 * to retrieve the value in the specified column. This is the |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
769 * class name used for custom mapping. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
770 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
771 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
772 @Override |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
773 public String getColumnClassName(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
774 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
775 try { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
776 final String MonetDBType = types[column - 1]; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
777 Class<?> type = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
778 if (conn != null) { |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
713
diff
changeset
|
779 final java.util.Map<String,Class<?>> map = conn.getTypeMap(); |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
780 if (map != null && map.containsKey(MonetDBType)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
781 type = (Class)map.get(MonetDBType); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
782 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
783 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
784 if (type == null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
785 // fallback to the standard SQL type Class mappings |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
713
diff
changeset
|
786 type = MonetDriver.getClassForType(JdbcSQLTypes[column - 1]); |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
787 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
788 if (type != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
789 return type.getCanonicalName(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
790 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
791 throw new SQLException("column type mapping null: " + MonetDBType, "M0M03"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
792 } catch (IndexOutOfBoundsException e) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
793 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
794 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
795 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
796 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
797 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
798 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
799 * A private utility method to check validity of column index number |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
800 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
801 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
802 * @throws SQLDataException when invalid column index number |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
803 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
804 private final void checkColumnIndexValidity(final int column) throws java.sql.SQLDataException { |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
805 if (column < 1 || column > colCount) |
713
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
806 throw MonetResultSet.newSQLInvalidColumnIndexException(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
807 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
808 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
809 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
810 * A private method to fetch the isNullable and isAutoincrement values |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
811 * combined for a specific column. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
812 * The fetched values are stored in the array caches. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
813 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
814 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
815 * @throws SQLException if there is no such column |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
816 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
817 private final void fetchColumnInfo(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
818 // for debug: System.out.println("fetchColumnInfo(" + column + ")"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
819 checkColumnIndexValidity(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
820 if (_is_fetched[column] != true) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
821 // fetch column info for multiple columns combined in one go |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
822 fetchManyColumnsInfo(column); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
823 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
824 if (_is_fetched[column]) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
825 return; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
826 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
827 // apparently no data could be fetched for this resultset column, fall back to defaults |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
828 _isNullable[column] = columnNullableUnknown; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
829 _isAutoincrement[column] = false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
830 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
831 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
832 /** |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
833 * A private method to fetch the isNullable and isAutoincrement values |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
834 * for many fully qualified columns combined in one SQL query to reduce the number of queries sent. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
835 * As fetching this meta information from the server per column is costly we combine the querying of |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
836 * the isNullable and isAutoincrement values and cache it in internal arrays. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
837 * We also do this for many columns combined in one query to reduce |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
838 * the number of queries needed for fetching this metadata for all resultset columns. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
839 * Many generic JDBC database tools (e.g. SQuirreL, DBeaver) request this meta data for each |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
840 * column of each resultset, so these optimisations reduces the number of meta data queries significantly. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
841 * |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
842 * @param column the first column is 1, the second is 2, ... |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
843 * @throws SQLException if a database access error occurs |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
844 */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
845 private final void fetchManyColumnsInfo(final int column) throws SQLException { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
846 // for debug: System.out.println("fetchManyColumnsInfo(" + column + ")"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
847 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
848 // Most queries have less than 80 resultset columns |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
849 // So 80 is a good balance between speedup (up to 79x) and size of generated query sent to server |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
850 final int MAX_COLUMNS_PER_QUERY = 80; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
851 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
852 // Determine the optimal startcol to make use of fetching up to 80 columns in one query. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
853 int startcol = column; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
854 if ((startcol > 1) && (startcol + MAX_COLUMNS_PER_QUERY >= nextUpperbound)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
855 // we can fetch info from more columns in one query if we start with a lower startcol |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
856 startcol = nextUpperbound - MAX_COLUMNS_PER_QUERY; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
857 if (startcol < 1) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
858 startcol = 1; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
859 } else |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
860 if (startcol > column) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
861 startcol = column; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
862 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
863 nextUpperbound = startcol; // next time this nextUpperbound value will be used |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
864 // for debug: System.out.println("fetchManyColumnsInfo(" + column + ")" + (startcol != column ? " changed into startcol: " + startcol : "") + " nextUpperbound: " + nextUpperbound); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
865 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
866 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
867 final StringBuilder query = new StringBuilder(410 + (MAX_COLUMNS_PER_QUERY * 150)); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
868 /* next SQL query is a simplified version of query in MonetDatabaseMetaData.getColumns(), to fetch only the needed attributes of a column */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
869 query.append("SELECT " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
870 "s.\"name\" AS schnm, " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
871 "t.\"name\" AS tblnm, " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
872 "c.\"name\" AS colnm, " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
873 "cast(CASE c.\"null\" WHEN true THEN ").append(ResultSetMetaData.columnNullable) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
874 .append(" WHEN false THEN ").append(ResultSetMetaData.columnNoNulls) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
875 .append(" ELSE ").append(ResultSetMetaData.columnNullableUnknown) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
876 .append(" END AS int) AS nullable, ").append( |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
877 "cast(CASE WHEN c.\"default\" IS NOT NULL AND c.\"default\" LIKE 'next value for %' THEN true ELSE false END AS boolean) AS isautoincrement " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
878 "FROM \"sys\".\"columns\" c " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
879 "JOIN \"sys\".\"tables\" t ON c.\"table_id\" = t.\"id\" " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
880 "JOIN \"sys\".\"schemas\" s ON t.\"schema_id\" = s.\"id\" " + |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
881 "WHERE "); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
882 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
883 /* combine the conditions for multiple (up to 80) columns into the WHERE-clause */ |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
884 String schName = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
885 String tblName = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
886 String colName = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
887 int queriedcolcount = 0; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
888 for (int col = startcol; col < array_size && queriedcolcount < MAX_COLUMNS_PER_QUERY; col++) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
889 if (_is_fetched[col] != true) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
890 if (_is_queried[col] != true) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
891 _isNullable[col] = columnNullableUnknown; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
892 _isAutoincrement[col] = false; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
893 schName = getSchemaName(col); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
894 if (schName != null && !schName.isEmpty()) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
895 tblName = getTableName(col); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
896 if (tblName != null && !tblName.isEmpty()) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
897 colName = getColumnName(col); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
898 if (colName != null && !colName.isEmpty()) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
899 if (queriedcolcount > 0) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
900 query.append(" OR "); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
901 query.append("(s.\"name\" = ").append(MonetWrapper.sq(schName)); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
902 query.append(" AND t.\"name\" = ").append(MonetWrapper.sq(tblName)); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
903 query.append(" AND c.\"name\" = ").append(MonetWrapper.sq(colName)); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
904 query.append(")"); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
905 _is_queried[col] = true; // flag it |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
906 queriedcolcount++; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
907 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
908 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
909 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
910 if (_is_queried[col] != true) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
911 // make sure we do not try to query it again next time as it is not queryable |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
912 _is_fetched[col] = true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
913 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
914 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
915 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
916 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
917 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
918 if (queriedcolcount == 0) |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
919 return; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
920 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
921 // execute query to get information on queriedcolcount (or less) columns. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
922 final java.sql.Statement stmt = conn.createStatement(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
923 if (stmt != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
924 // for debug: System.out.println("SQL (len " + query.length() + "): " + query.toString()); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
925 final java.sql.ResultSet rs = stmt.executeQuery(query.toString()); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
926 if (rs != null) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
927 String rsSchema = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
928 String rsTable = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
929 String rsColumn = null; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
930 while (rs.next()) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
931 rsSchema = rs.getString(1); // col 1 is schnm |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
932 rsTable = rs.getString(2); // col 2 is tblnm |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
933 rsColumn = rs.getString(3); // col 3 is colnm |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
934 // find the matching schema.table.column entry in the array |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
935 for (int col = 1; col < array_size; col++) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
936 if (_is_fetched[col] != true && _is_queried[col]) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
937 colName = getColumnName(col); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
938 if (colName != null && colName.equals(rsColumn)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
939 tblName = getTableName(col); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
940 if (tblName != null && tblName.equals(rsTable)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
941 schName = getSchemaName(col); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
942 if (schName != null && schName.equals(rsSchema)) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
943 // found matching entry |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
944 // for debug: System.out.println("Found match at [" + col + "] for " + schName + "." + tblName + "." + colName); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
945 _isNullable[col] = rs.getInt(4); // col 4 is nullable (or "NULLABLE") |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
946 _isAutoincrement[col] = rs.getBoolean(5); // col 5 is isautoincrement (or "IS_AUTOINCREMENT") |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
947 _is_fetched[col] = true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
948 queriedcolcount--; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
949 // we found the match, exit the for-loop |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
950 col = array_size; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
951 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
952 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
953 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
954 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
955 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
956 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
957 rs.close(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
958 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
959 stmt.close(); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
960 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
961 |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
962 if (queriedcolcount != 0) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
963 // not all queried columns have resulted in a returned data row. |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
964 // make sure we do not match those columns again next run |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
965 for (int col = startcol; col < array_size; col++) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
966 if (_is_fetched[col] != true && _is_queried[col]) { |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
967 _is_fetched[col] = true; |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
968 // for debug: System.out.println("Found NO match at [" + col + "] for " + getSchemaName(col) + "." + getTableName(col) + "." + getColumnName(col)); |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
969 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
970 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
971 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
972 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
973 } |
c3c424a90a42
Improve implementation of ResultSet.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
974 |