Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetParameterMetaData.java @ 937:d416e9b6b3d0
Update Copyright year.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 02 Jan 2025 13:27:58 +0100 (4 months ago) |
parents | 549225b7be85 |
children |
rev | line source |
---|---|
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
1 /* |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
758
diff
changeset
|
2 * SPDX-License-Identifier: MPL-2.0 |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
758
diff
changeset
|
3 * |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
4 * This Source Code Form is subject to the terms of the Mozilla Public |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
7 * |
937
d416e9b6b3d0
Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
888
diff
changeset
|
8 * Copyright 2024, 2025 MonetDB Foundation; |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
758
diff
changeset
|
9 * Copyright August 2008 - 2023 MonetDB B.V.; |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
758
diff
changeset
|
10 * Copyright 1997 - July 2008 CWI. |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
11 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
12 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
13 package org.monetdb.jdbc; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
14 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
15 import java.sql.ParameterMetaData; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
16 import java.sql.SQLDataException; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
17 import java.sql.SQLException; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
18 import java.sql.Types; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
19 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
20 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
21 *<pre> |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
22 * A {@link ParameterMetaData} suitable for the MonetDB database. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
23 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
24 * An object that can be used to get information about the types and properties |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
25 * for each parameter marker in a PreparedStatement or CallableStatement object. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
26 *</pre> |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
27 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
28 * @author Martin van Dinther |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
29 * @version 1.0 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
30 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
31 final class MonetParameterMetaData |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
32 extends MonetWrapper |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
33 implements ParameterMetaData |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
34 { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
35 /** The parental Connection object */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
36 private final MonetConnection conn; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
37 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
38 /** The number of parameters, it can be zero !! */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
39 private final int paramCount; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
40 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
41 /** The MonetDB type names of the parameters in the PreparedStatement */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
42 private final String[] monetdbTypes; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
43 /** The JDBC SQL type codes of the parameters in the PreparedStatement */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
44 private final int[] JdbcSQLTypes; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
45 /** The precisions of the parameters in the PreparedStatement */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
46 private final int[] precisions; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
47 /** The scales of the parameters in the PreparedStatement */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
48 private final int[] scales; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
49 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
50 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
51 * Constructor backed by the given connection and metadata arrays. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
52 * It is used by MonetPreparedStatement. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
53 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
54 * @param connection the parent connection |
720
99baab703566
Resolve some javac -Xdoclint warnings
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
719
diff
changeset
|
55 * @param paramcount the number of parameters, it can be zero !! |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
56 * @param types the MonetDB type names |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
57 * @param jdbcTypes the JDBC SQL type codes |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
58 * @param precisions the precision for each parameter |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
59 * @param scales the scale for each parameter |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
60 * @throws IllegalArgumentException if called with null for one of the arguments |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
61 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
62 MonetParameterMetaData( |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
63 final MonetConnection connection, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
64 final int paramcount, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
65 final String[] types, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
66 final int[] jdbcTypes, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
67 final int[] precisions, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
68 final int[] scales) |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
69 throws IllegalArgumentException |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
70 { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
71 if (connection == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
72 throw new IllegalArgumentException("Connection may not be null!"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
73 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
74 if (types == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
75 throw new IllegalArgumentException("MonetDB Types may not be null!"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
76 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
77 if (jdbcTypes == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
78 throw new IllegalArgumentException("JDBC Types may not be null!"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
79 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
80 if (precisions == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
81 throw new IllegalArgumentException("Precisions may not be null!"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
82 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
83 if (scales == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
84 throw new IllegalArgumentException("Scales may not be null!"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
85 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
86 if (types.length != precisions.length || types.length != (paramcount +1)) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
87 throw new IllegalArgumentException("Inconsistent Parameters metadata"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
88 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
89 this.conn = connection; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
90 this.paramCount = paramcount; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
91 this.monetdbTypes = types; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
92 this.JdbcSQLTypes = jdbcTypes; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
93 this.precisions = precisions; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
94 this.scales = scales; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
95 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
96 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
97 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
98 * Retrieves the number of parameters in the PreparedStatement object |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
99 * for which this ParameterMetaData object contains information. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
100 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
101 * @return the number of parameters |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
102 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
103 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
104 public int getParameterCount() { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
105 return paramCount; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
106 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
107 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
108 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
109 * Retrieves whether null values are allowed in the |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
110 * designated parameter. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
111 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
112 * This is currently always unknown for MonetDB/SQL. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
113 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
114 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
115 * @return the nullability status of the given parameter; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
116 * one of ParameterMetaData.parameterNoNulls, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
117 * ParameterMetaData.parameterNullable, or |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
118 * ParameterMetaData.parameterNullableUnknown |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
119 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
120 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
121 public int isNullable(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
122 checkParameterIndexValidity(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
123 return ParameterMetaData.parameterNullableUnknown; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
124 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
125 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
126 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
127 * Retrieves whether values for the designated parameter can |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
128 * be signed numbers. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
129 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
130 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
131 * @return true if so; false otherwise |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
132 * @throws SQLException if a database access error occurs |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
133 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
134 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
135 public boolean isSigned(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
136 // we can hardcode this, based on the parameter type |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
137 switch (getParameterType(param)) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
138 case Types.TINYINT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
139 case Types.SMALLINT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
140 case Types.INTEGER: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
141 case Types.REAL: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
142 case Types.FLOAT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
143 case Types.DOUBLE: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
144 case Types.DECIMAL: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
145 case Types.NUMERIC: |
885
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
146 case Types.DATE: // year can be negative |
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
147 case Types.TIMESTAMP: // year can be negative |
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
148 case Types.TIMESTAMP_WITH_TIMEZONE: |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
149 return true; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
150 case Types.BIGINT: |
885
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
151 { |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
152 final String monettype = getParameterTypeName(param); |
885
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
153 // data of type oid or ptr is not signed |
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
154 if ("oid".equals(monettype) |
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
155 || "ptr".equals(monettype)) |
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
156 return false; |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
157 return true; |
885
e1f00e0e3598
Improve isSigned() information on result columns and parameters of Types.DATE, Types.TIMESTAMP and Types.TIMESTAMP_WITH_TIMEZONE. These can have a negative year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
158 } |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
159 default: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
160 return false; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
161 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
162 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
163 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
164 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
165 * Retrieves the designated parameter's specified column size. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
166 * The returned value represents the maximum column size for |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
167 * the given parameter. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
168 * For numeric data, this is the maximum precision. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
169 * For character data, this is the length in characters. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
170 * For datetime datatypes, this is the length in characters |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
171 * of the String representation (assuming the maximum allowed |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
172 * precision of the fractional seconds component). |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
173 * For binary data, this is the length in bytes. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
174 * For the ROWID datatype, this is the length in bytes. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
175 * 0 is returned for data types where the column size is not applicable. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
176 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
177 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
178 * @return precision |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
179 * @throws SQLException if a database access error occurs |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
180 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
181 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
182 public int getPrecision(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
183 switch (getParameterType(param)) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
184 case Types.BIGINT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
185 return 19; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
186 case Types.INTEGER: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
187 return 10; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
188 case Types.SMALLINT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
189 return 5; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
190 case Types.TINYINT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
191 return 3; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
192 case Types.REAL: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
193 return 7; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
194 case Types.FLOAT: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
195 case Types.DOUBLE: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
196 return 15; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
197 case Types.DECIMAL: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
198 case Types.NUMERIC: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
199 // these data types have a variable precision (max precision is 38) |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
200 try { |
888
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
201 // Special handling for: day_interval and sec_interval as they are |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
202 // mapped to Types.NUMERIC and Types.DECIMAL types (see MonetDriver typeMap) |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
203 final String monettype = monetdbTypes[param]; |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
204 if (monettype != null && monettype.endsWith("_interval")) { |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
205 /* for interval types, precisions[] contains the interval subtype code */ |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
206 switch (precisions[param]) { |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
207 case 1: return 4; // interval year |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
208 case 2: return 6; // interval year to month |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
209 case 3: return 6; // interval month |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
210 case 4: return 9; // interval day |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
211 case 5: return 11; // interval day to hour |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
212 case 6: return 13; // interval day to minute |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
213 case 7: return 15; // interval day to second |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
214 case 8: return 11; // interval hour |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
215 case 9: return 13; // interval hour to minute |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
216 case 10: return 15; // interval hour to second |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
217 case 11: return 13; // interval minute |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
218 case 12: return 15; // interval minute to second |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
219 case 13: return 15; // interval second |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
220 default: |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
221 { // fall back to the 3 available monettype names |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
222 if ("sec_interval".equals(monettype)) |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
223 return 15; |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
224 if ("day_interval".equals(monettype)) |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
225 return 9; |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
226 if ("month_interval".equals(monettype)) |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
227 return 6; |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
228 } |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
229 } |
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
230 } |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
231 return precisions[param]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
232 } catch (IndexOutOfBoundsException e) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
233 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
234 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
235 case Types.CHAR: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
236 case Types.VARCHAR: |
735
3dd0d43014e8
Disable checks for Types.LONGVARCHAR and Types.LONGVARBINARY as MonetDB server does not support these data types, and no mappings exists to these JDBC Types and thus these cases will never be reached in JDBC Driver.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
720
diff
changeset
|
237 /* case Types.LONGVARCHAR: // MonetDB doesn't use type LONGVARCHAR */ |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
238 case Types.CLOB: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
239 // these data types have a variable length |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
240 try { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
241 return precisions[param]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
242 } catch (IndexOutOfBoundsException e) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
243 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
244 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
245 case Types.BINARY: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
246 case Types.VARBINARY: |
735
3dd0d43014e8
Disable checks for Types.LONGVARCHAR and Types.LONGVARBINARY as MonetDB server does not support these data types, and no mappings exists to these JDBC Types and thus these cases will never be reached in JDBC Driver.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
720
diff
changeset
|
247 /* case Types.LONGVARBINARY: // MonetDB doesn't use type LONGVARBINARY */ |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
248 case Types.BLOB: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
249 // these data types have a variable length |
735
3dd0d43014e8
Disable checks for Types.LONGVARCHAR and Types.LONGVARBINARY as MonetDB server does not support these data types, and no mappings exists to these JDBC Types and thus these cases will never be reached in JDBC Driver.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
720
diff
changeset
|
250 // It expects number of bytes, not number of hex chars |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
251 try { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
252 return precisions[param]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
253 } catch (IndexOutOfBoundsException e) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
254 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
255 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
256 case Types.DATE: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
257 return 10; // 2020-10-08 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
258 case Types.TIME: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
259 return 15; // 21:51:34.399753 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
260 case Types.TIME_WITH_TIMEZONE: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
261 return 21; // 21:51:34.399753+02:00 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
262 case Types.TIMESTAMP: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
263 return 26; // 2020-10-08 21:51:34.399753 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
264 case Types.TIMESTAMP_WITH_TIMEZONE: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
265 return 32; // 2020-10-08 21:51:34.399753+02:00 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
266 case Types.BOOLEAN: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
267 return 1; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
268 default: |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
269 // All other types should return 0 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
270 return 0; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
271 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
272 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
273 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
274 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
275 * Retrieves the designated parameter's number of digits to |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
276 * right of the decimal point. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
277 * 0 is returned for data types where the scale is not applicable. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
278 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
279 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
280 * @return scale |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
281 * @throws SQLException if a database access error occurs |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
282 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
283 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
284 public int getScale(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
285 checkParameterIndexValidity(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
286 try { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
287 return scales[param]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
288 } catch (IndexOutOfBoundsException e) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
289 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
290 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
291 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
292 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
293 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
294 * Retrieves the designated parameter's SQL type. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
295 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
296 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
297 * @return SQL type from java.sql.Types |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
298 * @throws SQLException if a database access error occurs |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
299 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
300 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
301 public int getParameterType(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
302 checkParameterIndexValidity(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
303 try { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
304 return JdbcSQLTypes[param]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
305 } catch (IndexOutOfBoundsException e) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
306 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
307 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
308 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
309 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
310 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
311 * Retrieves the designated parameter's database-specific type name. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
312 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
313 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
314 * @return type the name used by the database. If the |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
315 * parameter type is a user-defined type, then a |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
316 * fully-qualified type name is returned. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
317 * @throws SQLException if a database access error occurs |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
318 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
319 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
320 public String getParameterTypeName(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
321 checkParameterIndexValidity(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
322 try { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
323 final String monettype = monetdbTypes[param]; |
758
37eae5a78c1b
Add extra null check to prevent NPE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
735
diff
changeset
|
324 if (monettype != null && monettype.endsWith("_interval")) { |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
325 /* convert the interval type names to valid SQL data type names */ |
888
549225b7be85
Corrected ResultSetMetaData methods getPrecision(), getColumnDisplaySize() and ParameterMetaData method getPrecision() for the interval data types. They now return more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
887
diff
changeset
|
326 /* for interval types, precisions[] contains the interval subtype code */ |
887
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
327 switch (precisions[param]) { |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
328 case 1: return "interval year"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
329 case 2: return "interval year to month"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
330 case 3: return "interval month"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
331 case 4: return "interval day"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
332 case 5: return "interval day to hour"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
333 case 6: return "interval day to minute"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
334 case 7: return "interval day to second"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
335 case 8: return "interval hour"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
336 case 9: return "interval hour to minute"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
337 case 10: return "interval hour to second"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
338 case 11: return "interval minute"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
339 case 12: return "interval minute to second"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
340 case 13: return "interval second"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
341 default: |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
342 { // fall back to the 3 available monettype names |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
343 if ("day_interval".equals(monettype)) |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
344 return "interval day"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
345 if ("month_interval".equals(monettype)) |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
346 return "interval month"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
347 if ("sec_interval".equals(monettype)) |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
348 return "interval second"; |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
349 } |
674f9ed21308
Improved ResultSetMetaData.getColumnTypeName() and ParameterMetaData.getParameterTypeName() for interval types. It now returns more precise information for the 13 possible interval data types.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
885
diff
changeset
|
350 } |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
351 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
352 return monettype; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
353 } catch (IndexOutOfBoundsException e) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
354 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
355 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
356 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
357 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
358 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
359 * Retrieves the fully-qualified name of the Java class whose instances |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
360 * should be passed to the method PreparedStatement.setObject. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
361 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
362 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
363 * @return the fully-qualified name of the class in the Java |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
364 * programming language that would be used by the |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
365 * method PreparedStatement.setObject to set the |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
366 * value in the specified parameter. This is the |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
367 * class name used for custom mapping. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
368 * @throws SQLException if a database access error occurs |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
369 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
370 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
371 public String getParameterClassName(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
372 final String MonetDBType = getParameterTypeName(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
373 final java.util.Map<String,Class<?>> map = conn.getTypeMap(); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
374 final Class<?> type; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
375 if (map != null && map.containsKey(MonetDBType)) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
376 type = (Class)map.get(MonetDBType); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
377 } else { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
378 type = MonetDriver.getClassForType(getParameterType(param)); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
379 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
380 if (type != null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
381 return type.getCanonicalName(); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
382 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
383 throw new SQLException("parameter type mapping null: " + MonetDBType, "M0M03"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
384 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
385 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
386 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
387 * Retrieves the designated parameter's mode. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
388 * For MonetDB/SQL we currently only support INput parameters. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
389 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
390 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
391 * @return mode of the parameter; one of |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
392 * ParameterMetaData.parameterModeIn, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
393 * ParameterMetaData.parameterModeOut, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
394 * ParameterMetaData.parameterModeInOut or |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
395 * ParameterMetaData.parameterModeUnknown. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
396 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
397 @Override |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
398 public int getParameterMode(final int param) throws SQLException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
399 checkParameterIndexValidity(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
400 return ParameterMetaData.parameterModeIn; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
401 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
402 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
403 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
404 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
405 * A private utility method to check validity of parameter index number |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
406 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
407 * @param param - the first parameter is 1, the second is 2, ... |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
408 * @throws SQLDataException when invalid parameter index number |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
409 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
410 private final void checkParameterIndexValidity(final int param) throws SQLDataException { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
411 if (param < 1 || param > paramCount) |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
412 throw newSQLInvalidParameterIndexException(param); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
413 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
414 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
415 /** |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
416 * Small helper method that formats the "Invalid Parameter Index number ..." |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
417 * message and creates a new SQLDataException object whose SQLState is set |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
418 * to "22010": invalid indicator parameter value. |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
419 * |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
420 * @param paramIdx the parameter index number |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
421 * @return a new created SQLDataException object with SQLState 22010 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
422 */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
423 private final SQLDataException newSQLInvalidParameterIndexException(final int paramIdx) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
424 return new SQLDataException("Invalid Parameter Index number: " + paramIdx, "22010"); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
425 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
426 } |