annotate src/main/java/org/monetdb/jdbc/MonetParameterMetaData.java @ 833:e890195256ac

Update copyright for the new year, move to MonetDB Foundation, add SPDX.
author Sjoerd Mullender <sjoerd@acm.org>
date Fri, 29 Dec 2023 14:37:42 +0100 (15 months ago)
parents 37eae5a78c1b
children e1f00e0e3598
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
833
e890195256ac Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents: 758
diff changeset
8 * Copyright 2024 MonetDB Foundation;
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:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
146 return true;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
147 case Types.BIGINT:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
148 final String monettype = getParameterTypeName(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
149 if (monettype != null && monettype.length() == 3) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
150 // data of type oid or ptr is not signed
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
151 if ("oid".equals(monettype)
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
152 || "ptr".equals(monettype))
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
153 return false;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
154 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
155 return true;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
156 // All other types should return false
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
157 // case Types.BOOLEAN:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
158 // case Types.DATE: // can year be negative?
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
159 // case Types.TIME: // can time be negative?
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
160 // case Types.TIME_WITH_TIMEZONE:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
161 // case Types.TIMESTAMP: // can year be negative?
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
162 // case Types.TIMESTAMP_WITH_TIMEZONE:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
163 default:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
164 return false;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
165 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
166 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
167
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
168 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
169 * 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
170 * 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
171 * the given parameter.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
172 * 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
173 * 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
174 * 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
175 * 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
176 * precision of the fractional seconds component).
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
177 * 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
178 * 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
179 * 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
180 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
181 * @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
182 * @return precision
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
183 * @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
184 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
185 @Override
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
186 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
187 switch (getParameterType(param)) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
188 case Types.BIGINT:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
189 return 19;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
190 case Types.INTEGER:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
191 return 10;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
192 case Types.SMALLINT:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
193 return 5;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
194 case Types.TINYINT:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
195 return 3;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
196 case Types.REAL:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
197 return 7;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
198 case Types.FLOAT:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
199 case Types.DOUBLE:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
200 return 15;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
201 case Types.DECIMAL:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
202 case Types.NUMERIC:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
203 // 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
204 try {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
205 return precisions[param];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
206 } catch (IndexOutOfBoundsException e) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
207 throw newSQLInvalidParameterIndexException(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
208 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
209 case Types.CHAR:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
210 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
211 /* 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
212 case Types.CLOB:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
213 // these data types have a variable length
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
214 try {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
215 return precisions[param];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
216 } catch (IndexOutOfBoundsException e) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
217 throw newSQLInvalidParameterIndexException(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
218 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
219 case Types.BINARY:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
220 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
221 /* 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
222 case Types.BLOB:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
223 // 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
224 // 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
225 try {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
226 return precisions[param];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
227 } catch (IndexOutOfBoundsException e) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
228 throw newSQLInvalidParameterIndexException(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
229 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
230 case Types.DATE:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
231 return 10; // 2020-10-08
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
232 case Types.TIME:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
233 return 15; // 21:51:34.399753
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
234 case Types.TIME_WITH_TIMEZONE:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
235 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
236 case Types.TIMESTAMP:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
237 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
238 case Types.TIMESTAMP_WITH_TIMEZONE:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
239 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
240 case Types.BOOLEAN:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
241 return 1;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
242 default:
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
243 // All other types should return 0
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
244 return 0;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
245 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
246 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
247
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
248 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
249 * 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
250 * right of the decimal point.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
251 * 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
252 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
253 * @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
254 * @return scale
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
255 * @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
256 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
257 @Override
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
258 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
259 checkParameterIndexValidity(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
260 try {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
261 return scales[param];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
262 } catch (IndexOutOfBoundsException e) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
263 throw newSQLInvalidParameterIndexException(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
264 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
265 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
266
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
267 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
268 * Retrieves the designated parameter's SQL type.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
269 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
270 * @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
271 * @return SQL type from java.sql.Types
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
272 * @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
273 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
274 @Override
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
275 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
276 checkParameterIndexValidity(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
277 try {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
278 return JdbcSQLTypes[param];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
279 } catch (IndexOutOfBoundsException e) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
280 throw newSQLInvalidParameterIndexException(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
281 }
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
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
284 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
285 * 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
286 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
287 * @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
288 * @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
289 * 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
290 * fully-qualified type name is returned.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
291 * @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
292 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
293 @Override
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
294 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
295 checkParameterIndexValidity(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
296 try {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
297 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
298 if (monettype != null && monettype.endsWith("_interval")) {
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
299 /* convert the interval type names to valid SQL data type names */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
300 if ("day_interval".equals(monettype))
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
301 return "interval day";
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
302 if ("month_interval".equals(monettype))
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
303 return "interval month";
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
304 if ("sec_interval".equals(monettype))
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
305 return "interval second";
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
306 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
307 return monettype;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
308 } catch (IndexOutOfBoundsException e) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
309 throw newSQLInvalidParameterIndexException(param);
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 }
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 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
314 * 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
315 * 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
316 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
317 * @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
318 * @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
319 * 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
320 * method PreparedStatement.setObject to set the
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
321 * 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
322 * class name used for custom mapping.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
323 * @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
324 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
325 @Override
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
326 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
327 final String MonetDBType = getParameterTypeName(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
328 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
329 final Class<?> type;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
330 if (map != null && map.containsKey(MonetDBType)) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
331 type = (Class)map.get(MonetDBType);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
332 } else {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
333 type = MonetDriver.getClassForType(getParameterType(param));
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
334 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
335 if (type != null) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
336 return type.getCanonicalName();
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
337 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
338 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
339 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
340
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
341 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
342 * Retrieves the designated parameter's mode.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
343 * 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
344 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
345 * @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
346 * @return mode of the parameter; one of
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
347 * ParameterMetaData.parameterModeIn,
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
348 * ParameterMetaData.parameterModeOut,
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
349 * ParameterMetaData.parameterModeInOut or
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
350 * ParameterMetaData.parameterModeUnknown.
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 @Override
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
353 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
354 checkParameterIndexValidity(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
355 return ParameterMetaData.parameterModeIn;
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 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
360 * 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
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 * @throws SQLDataException when invalid parameter index number
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
364 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
365 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
366 if (param < 1 || param > paramCount)
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
367 throw newSQLInvalidParameterIndexException(param);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
368 }
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 /**
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
371 * 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
372 * 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
373 * to "22010": invalid indicator parameter value.
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
374 *
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
375 * @param paramIdx the parameter index number
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
376 * @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
377 */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
378 private final SQLDataException newSQLInvalidParameterIndexException(final int paramIdx) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
379 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
380 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff changeset
381 }