annotate src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @ 973:32f246853ec4 default tip

Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 10 Apr 2025 19:26:59 +0200 (4 hours ago)
parents 5cc071c5c170
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1 /*
833
e890195256ac Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents: 815
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: 815
diff changeset
3 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
4 * This Source Code Form is subject to the terms of the Mozilla Public
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
7 *
937
d416e9b6b3d0 Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 894
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: 815
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: 815
diff changeset
10 * Copyright 1997 - July 2008 CWI.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
11 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
12
391
f523727db392 Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 382
diff changeset
13 package org.monetdb.jdbc;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
14
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
15 import java.io.InputStream;
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
16 import java.io.IOException;
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
17 import java.io.Reader;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
18 import java.math.BigDecimal;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
19 import java.math.BigInteger;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
20 import java.net.URL;
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
21 import java.nio.CharBuffer;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
22 import java.sql.Array;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
23 import java.sql.Blob;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
24 import java.sql.Clob;
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
25 import java.sql.Date;
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
26 import java.sql.NClob;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
27 import java.sql.ParameterMetaData;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
28 import java.sql.PreparedStatement;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
29 import java.sql.Ref;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
30 import java.sql.ResultSet;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
31 import java.sql.ResultSetMetaData;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
32 import java.sql.RowId;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
33 import java.sql.SQLData;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
34 import java.sql.SQLDataException;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
35 import java.sql.SQLException;
266
eefa7f625673 Resolve javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 262
diff changeset
36 import java.sql.SQLFeatureNotSupportedException;
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
37 import java.sql.SQLOutput;
376
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
38 import java.sql.SQLType; // new as of Java 1.8
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
39 import java.sql.SQLXML;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
40 import java.sql.Struct;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
41 import java.sql.Time;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
42 import java.sql.Timestamp;
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
43 import java.sql.Types;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
44 import java.text.SimpleDateFormat;
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
45 import java.util.Calendar;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
46
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
47 /**
451
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
48 *<pre>
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
49 * A {@link PreparedStatement} suitable for the MonetDB database.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
50 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
51 * This implementation of the PreparedStatement interface uses the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
52 * capabilities of the MonetDB/SQL backend to prepare and execute
269
9c1ecdbbd9aa Extend getColumnClassName() by also checking the connection's typeMap for Class names for types url and inet. Similar code as used in getParameterClassName().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 266
diff changeset
53 * statements. The backend takes care of finding the '?'s in the input and
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
54 * returns the types it expects for them.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
55 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
56 * An example of a server response on a prepare query is:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
57 * % prepare select name from tables where id &gt; ? and id &lt; ?;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
58 * &amp;5 0 2 3 2
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
59 * # prepare, prepare, prepare # table_name
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
60 * # type, digits, scale # name
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
61 * # varchar, int, int # type
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
62 * # 0, 0, 0 # length
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
63 * [ "int", 9, 0 ]
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
64 * [ "int", 9, 0 ]
451
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
65 *</pre>
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
66 *
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
67 * @author Fabian Groffen
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
68 * @author Martin van Dinther
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
69 * @version 0.8
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
70 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
71 public class MonetPreparedStatement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
72 extends MonetStatement
164
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 163
diff changeset
73 implements PreparedStatement, AutoCloseable
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
74 {
450
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
75 private final String sqlStatement;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
76 private final String[] monetdbType;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
77 private final int[] javaType;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
78 private final int[] digits;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
79 private final int[] scale;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
80 private final String[] schema;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
81 private final String[] table;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
82 private final String[] column;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
83 private final int id;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
84 private final int size;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
85
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
86 private final int paramCount;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
87 private final int paramStartIndex;
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
88 private final String[] paramValues;
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
89
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
90 /** A cache to reduce the number of ResultSetMetaData objects created
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
91 * by getMetaData() to maximum 1 per PreparedStatement */
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
92 private ResultSetMetaData rsmd;
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
93
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
94 /** A cache to reduce the number of ParameterMetaData objects created
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
95 * by getParameterMetaData() to maximum 1 per PreparedStatement */
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
96 private ParameterMetaData pmd;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
97
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
98 /* placeholders for date/time pattern formats created once (only when needed), used multiple times */
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
99 /** Format of a timestamp with RFC822 time zone */
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
100 private SimpleDateFormat mTimestampZ;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
101 /** Format of a timestamp */
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
102 private SimpleDateFormat mTimestamp;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
103 /** Format of a time with RFC822 time zone */
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
104 private SimpleDateFormat mTimeZ;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
105 /** Format of a time */
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
106 private SimpleDateFormat mTime;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
107 /** Format of a date used by mserver */
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
108 private SimpleDateFormat mDate;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
109
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
110 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
111 * MonetPreparedStatement constructor which checks the arguments for
624
71bcc7af90be Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
112 * validity. A MonetPreparedStatement is backed by a {@link MonetStatement},
71bcc7af90be Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
113 * which deals with most of the required stuff of this class.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
114 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
115 * @param connection the connection that created this Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
116 * @param resultSetType type of {@link ResultSet} to produce
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
117 * @param resultSetConcurrency concurrency of ResultSet to produce
624
71bcc7af90be Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
118 * @param resultSetHoldability holdability of ResultSet to produce
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
119 * @param prepareQuery the query string to prepare
624
71bcc7af90be Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
120 * @throws SQLException if an error occurs during execution of the prepareQuery
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
121 * @throws IllegalArgumentException is one of the arguments is null or empty
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
122 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
123 MonetPreparedStatement(
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
124 final MonetConnection connection,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
125 final int resultSetType,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
126 final int resultSetConcurrency,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
127 final int resultSetHoldability,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
128 final String prepareQuery)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
129 throws SQLException, IllegalArgumentException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
130 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
131 super(
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
132 connection,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
133 resultSetType,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
134 resultSetConcurrency,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
135 resultSetHoldability
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
136 );
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
137
691
fb55e62c50f3 Fixed an invalid error issue when a PreparedStatement had more than 250 parameters.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 683
diff changeset
138 if (prepareQuery == null)
fb55e62c50f3 Fixed an invalid error issue when a PreparedStatement had more than 250 parameters.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 683
diff changeset
139 throw new SQLException("Missing SQL statement", "M1M05");
fb55e62c50f3 Fixed an invalid error issue when a PreparedStatement had more than 250 parameters.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 683
diff changeset
140
711
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
141 /**
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
142 * For a PREPARE statement the server sends back a result set
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
143 * with info on all the result columns and parameters of a
711
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
144 * parameterized query. This result set however needs to be
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
145 * read in one DataBlockResponse due to protocol limitations.
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
146 * This requires the fetchSize needs to be set large enough
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
147 * to retrieve all rows in one go, else we get error:
711
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
148 * <pre>resultBlocks[1] should have been fetched by now</pre>
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
149 * See also: https://github.com/MonetDB/MonetDB/issues/7337
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
150 */
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
151 final int originalFetchSize = getFetchSize();
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
152 // increase the fetchSize temporarily before sending the PREPARE statement
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
153 // we can not use -1 (unlimited), so use a high value.
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
154 setFetchSize(50*1000);
691
fb55e62c50f3 Fixed an invalid error issue when a PreparedStatement had more than 250 parameters.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 683
diff changeset
155
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
156 if (!super.execute("PREPARE " + prepareQuery))
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
157 throw new SQLException("Unexpected server response", "M0M10");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
158
711
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
159 setFetchSize(originalFetchSize);
5244af37a8e2 Counting only parameter markers to determine the fetchSize is not sufficiant for all Prepared statements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
160
450
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
161 sqlStatement = prepareQuery;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
162 // cheat a bit to get the ID and the number of columns
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
163 id = ((MonetConnection.ResultSetResponse)header).id;
377
8a813f5cef1b Extend StartOfHeaderParser with method getNextAsLong() and change type of tuplecount to long.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 376
diff changeset
164 size = (int)((MonetConnection.ResultSetResponse)header).tuplecount;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
165
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
166 int countParam = 0;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
167 int firstParamOffset = 0;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
168
889
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
169 // initialise metadata arrays. size can be 0.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
170 monetdbType = new String[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
171 javaType = new int[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
172 digits = new int[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
173 scale = new int[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
174 schema = new String[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
175 table = new String[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
176 column = new String[size];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
177
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
178 // fill the arrays
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
179 final ResultSet rs = super.getResultSet();
160
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
180 if (rs != null) {
165
8415c37c0ab4 Added clarification on the meaning of the contents of column[] which contains both possible query result columns and possible parameters.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 164
diff changeset
181 // System.out.println("After super.getResultSet();");
973
32f246853ec4 Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 967
diff changeset
182 final boolean mapClobAsVarChar = connection.mapClobAsVarChar();
32f246853ec4 Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 967
diff changeset
183 final boolean mapBlobAsVarBinary = connection.mapBlobAsVarBinary();
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
184 final int type_colnr = rs.findColumn("type");
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
185 final int digits_colnr = rs.findColumn("digits");
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
186 final int scale_colnr = rs.findColumn("scale");
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
187 final int schema_colnr = rs.findColumn("schema");
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
188 final int table_colnr = rs.findColumn("table");
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
189 final int column_colnr = rs.findColumn("column");
889
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
190 for (int i = 0; rs.next() && i < size; i++) {
160
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
191 monetdbType[i] = rs.getString(type_colnr);
223
e8139dbe3883 Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
192 javaType[i] = MonetDriver.getJdbcSQLType(monetdbType[i]);
973
32f246853ec4 Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 967
diff changeset
193 if (javaType[i] == Types.CLOB && mapClobAsVarChar) {
32f246853ec4 Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 967
diff changeset
194 javaType[i] = Types.VARCHAR;
175
8700d9ef2ace Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 166
diff changeset
195 } else
973
32f246853ec4 Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 967
diff changeset
196 if (javaType[i] == Types.BLOB && mapBlobAsVarBinary) {
32f246853ec4 Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 967
diff changeset
197 javaType[i] = Types.VARBINARY;
175
8700d9ef2ace Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 166
diff changeset
198 }
160
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
199 digits[i] = rs.getInt(digits_colnr);
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
200 scale[i] = rs.getInt(scale_colnr);
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
201 schema[i] = rs.getString(schema_colnr);
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
202 table[i] = rs.getString(table_colnr);
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
203 column[i] = rs.getString(column_colnr);
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
204 // System.out.println("column " + i + " has value: " + column[i]);
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
205 /* when column[i] != null it is a result column of the prepared query,
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
206 * when column[i] == null it is a parameter for the prepared statement.
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
207 * Note that we always get the result columns (if any) first and
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
208 * next the parameters (if any) in the columns[].
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
209 */
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
210 if (column[i] == null) {
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
211 countParam++;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
212 if (countParam == 1)
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
213 firstParamOffset = i; // remember where the first parameter is stored
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
214 }
160
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
215 }
763150ec0a0a Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 159
diff changeset
216 rs.close();
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
217 }
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
218 paramCount = countParam;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
219 paramStartIndex = firstParamOffset;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
220 // System.out.println("paramCount= " + paramCount + " paramStartIndex= " + paramStartIndex + "\n");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
221
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
222 paramValues = new String[paramCount + 1]; // parameters start from 1
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
223
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
224 // PreparedStatements are by default poolable
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
225 poolable = true;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
226 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
227
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
228
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
229 //== methods interface PreparedStatement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
230
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
231 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
232 * Adds a set of parameters to this PreparedStatement object's batch
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
233 * of commands.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
234 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
235 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
236 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
237 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
238 public void addBatch() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
239 super.addBatch(transform());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
240 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
241
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
242 /** override the addBatch from the Statement to throw an SQLException */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
243 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
244 public void addBatch(final String q) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
245 throw new SQLException("This method is not available in a PreparedStatement!", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
246 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
247
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
248 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
249 * Clears the current parameter values immediately.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
250 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
251 * In general, parameter values remain in force for repeated use of a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
252 * statement. Setting a parameter value automatically clears its previous
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
253 * value. However, in some cases it is useful to immediately release the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
254 * resources used by the current parameter values; this can be done by
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
255 * calling the method clearParameters.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
256 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
257 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
258 public void clearParameters() {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
259 for (int param = 1; param <= paramCount; param++) {
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
260 paramValues[param] = null;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
261 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
262 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
263
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
264 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
265 * Executes the SQL statement in this PreparedStatement object,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
266 * which may be any kind of SQL statement. Some prepared statements
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
267 * return multiple results; the execute method handles these complex
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
268 * statements as well as the simpler form of statements handled by
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
269 * the methods executeQuery and executeUpdate.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
270 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
271 * The execute method returns a boolean to indicate the form of the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
272 * first result. You must call either the method getResultSet or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
273 * getUpdateCount to retrieve the result; you must call
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
274 * getMoreResults to move to any subsequent result(s).
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
275 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
276 * @return true if the first result is a ResultSet object; false if the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
277 * first result is an update count or there is no result
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
278 * @throws SQLException if a database access error occurs or an argument
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
279 * is supplied to this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
280 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
281 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
282 public boolean execute() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
283 return super.execute(transform());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
284 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
285
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
286 /** override the execute from the Statement to throw an SQLException */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
287 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
288 public boolean execute(final String q) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
289 throw new SQLException("This method is not available in a PreparedStatement!", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
290 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
291
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
292 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
293 * Executes the SQL query in this PreparedStatement object and returns the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
294 * ResultSet object generated by the query.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
295 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
296 * @return a ResultSet object that contains the data produced by the query;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
297 * never null
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
298 * @throws SQLException if a database access error occurs or the SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
299 * statement does not return a ResultSet object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
300 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
301 @Override
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
302 public ResultSet executeQuery() throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
303 if (execute() != true)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
304 throw new SQLException("Query did not produce a result set", "M1M19");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
305
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
306 return getResultSet();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
307 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
308
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
309 /** override the executeQuery from the Statement to throw an SQLException */
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
310 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
311 public ResultSet executeQuery(final String q) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
312 throw new SQLException("This method is not available in a PreparedStatement!", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
313 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
314
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
315 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
316 * Executes the SQL statement in this PreparedStatement object, which must
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
317 * be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
318 * returns nothing, such as a DDL statement.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
319 *
490
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
320 * @return either (1) the row count for INSERT, UPDATE, or DELETE statements
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
321 * or (2) 0 for SQL statements that return nothing
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
322 * @throws SQLException if a database access error occurs or the SQL
490
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
323 * statement returns a ResultSet object
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
324 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
325 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
326 public int executeUpdate() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
327 if (execute() != false)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
328 throw new SQLException("Query produced a result set", "M1M17");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
329
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
330 return Math.max(getUpdateCount(), 0);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
331 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
332
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
333 /** override the executeUpdate from the Statement to throw an SQLException */
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
334 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
335 public int executeUpdate(final String q) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
336 throw new SQLException("This method is not available in a PreparedStatement!", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
337 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
338
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
339 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
340 * Retrieves a ResultSetMetaData object that contains information
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
341 * about the columns of the ResultSet object that will be returned
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
342 * when this PreparedStatement object is executed.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
343 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
344 * Because a PreparedStatement object is precompiled, it is possible
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
345 * to know about the ResultSet object that it will return without
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
346 * having to execute it. Consequently, it is possible to invoke the
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
347 * method getMetaData on a PreparedStatement object rather than
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
348 * waiting to execute it and then invoking the ResultSet.getMetaData
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
349 * method on the ResultSet object that is returned.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
350 *
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
351 * @return the description of a ResultSet object's columns or null if
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
352 * the driver cannot return a ResultSetMetaData object
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
353 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
354 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
355 @Override
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 186
diff changeset
356 public ResultSetMetaData getMetaData() throws SQLException {
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
357 if (rsmd == null) {
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
358 // first use, construct the arrays with metadata and a
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
359 // ResultSetMetaData object once and reuse it for all next calls
889
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
360 final int rescolcount = size - paramCount; // this can be 0
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
361 // create arrays for storing only the result columns meta data
889
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
362 final String[] schemas = new String[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
363 final String[] tables = new String[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
364 final String[] columns = new String[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
365 final String[] types = new String[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
366 final int[] jdbcTypes = new int[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
367 final int[] lengths = new int[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
368 final int[] precisions = new int[rescolcount];
485c75b35cc9 An array_size of 0 (so new String[0]) is allowed in java.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 884
diff changeset
369 final int[] scales = new int[rescolcount];
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
370 // fill the arrays with the resultset columns metadata
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
371 for (int i = 0; i < rescolcount; i++) {
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
372 schemas[i] = schema[i];
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
373 tables[i] = table[i];
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
374 columns[i] = column[i];
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
375 types[i] = monetdbType[i];
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
376 jdbcTypes[i] = javaType[i];
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
377 switch (jdbcTypes[i]) {
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
378 case Types.BIGINT:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
379 lengths[i] = 19;
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
380 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
381 case Types.INTEGER:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
382 lengths[i] = 10;
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
383 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
384 case Types.SMALLINT:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
385 lengths[i] = 5;
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
386 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
387 case Types.TINYINT:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
388 lengths[i] = 3;
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
389 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
390 case Types.REAL:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
391 lengths[i] = 7;
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
392 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
393 case Types.FLOAT:
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
394 case Types.DOUBLE:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
395 lengths[i] = 15;
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
396 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
397 case Types.DATE:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
398 lengths[i] = 10; // 2020-10-08
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
399 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
400 case Types.TIME:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
401 lengths[i] = 15; // 21:51:34.399753
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
402 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
403 case Types.TIME_WITH_TIMEZONE:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
404 lengths[i] = 21; // 21:51:34.399753+02:00
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
405 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
406 case Types.TIMESTAMP:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
407 lengths[i] = 26; // 2020-10-08 21:51:34.399753
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
408 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
409 case Types.TIMESTAMP_WITH_TIMEZONE:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
410 lengths[i] = 32; // 2020-10-08 21:51:34.399753+02:00
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
411 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
412 case Types.BOOLEAN:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
413 lengths[i] = 5; // true or false
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
414 break;
667
ed3d0c1a60cf Corrected PreparedStatement methods getMetaData().getColumnDisplaySize(), getMetaData().getPrecision() and getParameterMetaData().getPrecision().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 642
diff changeset
415 default:
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
416 lengths[i] = digits[i];
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
417 }
884
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
418 precisions[i] = digits[i];
1956d8ba5ad3 Optimise getMetaData(). We can compute the number of result columns, so avoid to go through all metadata entries in column[] to test if it is a result column.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 883
diff changeset
419 scales[i] = scale[i];
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
420 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
421
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
422 rsmd = new MonetResultSetMetaData((MonetConnection) getConnection(), rescolcount,
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
423 schemas, tables, columns, types, jdbcTypes, lengths, precisions, scales);
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
424 }
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
425 return rsmd;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
426 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
427
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
428 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
429 * Retrieves the number, types and properties of this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
430 * PreparedStatement object's parameters.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
431 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
432 * @return a ParameterMetaData object that contains information
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
433 * about the number, types and properties for each parameter
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
434 * marker of this PreparedStatement object
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
435 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
436 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
437 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
438 public ParameterMetaData getParameterMetaData() throws SQLException {
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
439 if (pmd == null) {
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
440 // first use, construct the arrays with metadata and a
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
441 // ParameterMetaData object once and reuse it for all next calls
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
442 final int array_size = paramCount +1;
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
443 // create arrays for storing only the parameters meta data
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
444 final String[] types = new String[array_size];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
445 final int[] jdbcTypes = new int[array_size];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
446 final int[] precisions = new int[array_size];
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
447 final int[] scales = new int[array_size];
883
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
448 if (paramCount > 0) {
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
449 // fill the arrays with the parameters metadata
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
450 int param = 1; // parameters in JDBC start from 1
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
451 for (int i = paramStartIndex; i < size && param <= paramCount; i++) {
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
452 types[param] = monetdbType[i];
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
453 jdbcTypes[param] = javaType[i];
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
454 precisions[param] = digits[i];
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
455 scales[param] = scale[i];
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
456 param++;
333bbac1e3e8 Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 873
diff changeset
457 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
458 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
459
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
460 pmd = new MonetParameterMetaData((MonetConnection) getConnection(),
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
461 paramCount, types, jdbcTypes, precisions, scales);
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
462 }
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
463 return pmd;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
464 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
465
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
466 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
467 * Sets the designated parameter to the given Array object. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
468 * driver converts this to an SQL ARRAY value when it sends it to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
469 * the database.
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
470 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
471 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
472 * @param x an Array object that maps an SQL ARRAY value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
473 * @throws SQLException if a database access error occurs
262
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
474 * @throws SQLFeatureNotSupportedException the JDBC driver does
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
475 * not support this method
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
476 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
477 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
478 public void setArray(final int parameterIndex, final Array x) throws SQLException {
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
479 throw newSQLFeatureNotSupportedException("setArray");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
480 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
481
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
482 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
483 * Sets the designated parameter to the given input stream, which will have
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
484 * the specified number of bytes. When a very large ASCII value is input to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
485 * a LONGVARCHAR parameter, it may be more practical to send it via a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
486 * java.io.InputStream. Data will be read from the stream as needed until
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
487 * end-of-file is reached. The JDBC driver will do any necessary conversion
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
488 * from ASCII to the database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
489 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
490 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
491 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
492 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
493 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
494 * @param x the Java input stream that contains the ASCII parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
495 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
496 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
497 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
498 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
499 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
500 public void setAsciiStream(final int parameterIndex, final InputStream x)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
501 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
502 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
503 throw newSQLFeatureNotSupportedException("setAsciiStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
504 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
505
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
506 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
507 * Sets the designated parameter to the given input stream, which will have
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
508 * the specified number of bytes. When a very large ASCII value is input to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
509 * a LONGVARCHAR parameter, it may be more practical to send it via a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
510 * java.io.InputStream. Data will be read from the stream as needed until
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
511 * end-of-file is reached. The JDBC driver will do any necessary conversion
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
512 * from ASCII to the database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
513 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
514 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
515 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
516 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
517 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
518 * @param x the Java input stream that contains the ASCII parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
519 * @param length the number of bytes in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
520 * @throws SQLException if a database access error occurs
262
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
521 * @throws SQLFeatureNotSupportedException the JDBC driver does
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
522 * not support this method
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
523 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
524 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
525 public void setAsciiStream(final int parameterIndex, final InputStream x, final int length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
526 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
527 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
528 throw newSQLFeatureNotSupportedException("setAsciiStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
529 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
530
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
531 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
532 * Sets the designated parameter to the given input stream, which
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
533 * will have the specified number of bytes. When a very large ASCII
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
534 * value is input to a LONGVARCHAR parameter, it may be more
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
535 * practical to send it via a java.io.InputStream. Data will be read
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
536 * from the stream as needed until end-of-file is reached. The JDBC
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
537 * driver will do any necessary conversion from ASCII to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
538 * database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
539 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
540 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
541 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
542 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
543 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
544 * @param x the Java input stream that contains the ASCII parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
545 * @param length the number of bytes in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
546 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
547 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
548 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
549 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
550 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
551 public void setAsciiStream(final int parameterIndex, final InputStream x, final long length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
552 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
553 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
554 throw newSQLFeatureNotSupportedException("setAsciiStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
555 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
556
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
557 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
558 * Sets the designated parameter to the given java.math.BigDecimal value.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
559 * The driver converts this to an SQL NUMERIC value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
560 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
561 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
562 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
563 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
564 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
565 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
566 @Override
894
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
567 public void setBigDecimal(final int parameterIndex, final BigDecimal x) throws SQLException
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
568 {
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
569 if (x == null) {
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
570 setValue(parameterIndex, "NULL");
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
571 return;
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
572 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
573
894
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
574 // get array position
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
575 final int i = getParamIdx(parameterIndex);
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
576 // round to the scale of the DB specification:
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
577 final BigDecimal decval = x.setScale(scale[i], java.math.RoundingMode.HALF_UP);
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
578 final String decvalStr = decval.toPlainString();
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
579
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
580 // if precision is now greater than that of the DB specification, throw an error:
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
581 if (decval.precision() > digits[i]) {
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
582 throw new SQLDataException("DECIMAL value '" + decvalStr + "' exceeds allowed digits,scale: (" + digits[i] + "," + scale[i] + ")", "22003");
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
583 }
07a4998898a8 Improve and optimize PreparedStatement.setBigDecimal() implementation. It now checks on null input parameter to prevent NPE. Also removed code to trim leading zero's.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 890
diff changeset
584 setValue(parameterIndex, decvalStr);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
585 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
586
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
587 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
588 * Sets the designated parameter to the given input stream, which will have
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
589 * the specified number of bytes. When a very large binary value is input
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
590 * to a LONGVARBINARY parameter, it may be more practical to send it via a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
591 * java.io.InputStream object. The data will be read from the stream as
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
592 * needed until end-of-file is reached.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
593 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
594 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
595 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
596 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
597 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
598 * @param x the java input stream which contains the binary parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
599 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
600 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
601 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
602 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
603 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
604 public void setBinaryStream(final int parameterIndex, final InputStream x)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
605 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
606 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
607 throw newSQLFeatureNotSupportedException("setBinaryStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
608 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
609
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
610 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
611 * Sets the designated parameter to the given input stream, which will have
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
612 * the specified number of bytes. When a very large binary value is input
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
613 * to a LONGVARBINARY parameter, it may be more practical to send it via a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
614 * java.io.InputStream object. The data will be read from the stream as
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
615 * needed until end-of-file is reached.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
616 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
617 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
618 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
619 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
620 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
621 * @param x the java input stream which contains the binary parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
622 * @param length the number of bytes in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
623 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
624 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
625 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
626 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
627 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
628 public void setBinaryStream(final int parameterIndex, final InputStream x, final int length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
629 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
630 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
631 throw newSQLFeatureNotSupportedException("setBinaryStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
632 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
633
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
634 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
635 * Sets the designated parameter to the given input stream, which will have
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
636 * the specified number of bytes. When a very large binary value is input
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
637 * to a LONGVARBINARY parameter, it may be more practical to send it via a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
638 * java.io.InputStream object. The data will be read from the stream as
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
639 * needed until end-of-file is reached.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
640 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
641 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
642 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
643 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
644 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
645 * @param x the java input stream which contains the binary parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
646 * @param length the number of bytes in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
647 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
648 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
649 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
650 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
651 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
652 public void setBinaryStream(final int parameterIndex, final InputStream x, final long length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
653 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
654 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
655 throw newSQLFeatureNotSupportedException("setBinaryStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
656 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
657
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
658 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
659 * Sets the designated parameter to the given Blob object. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
660 * converts this to an SQL BLOB value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
661 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
662 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
663 * @param x a Blob object that maps an SQL BLOB value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
664 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
665 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
666 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
667 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
668 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
669 public void setBlob(final int parameterIndex, final InputStream x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
670 throw newSQLFeatureNotSupportedException("setBlob");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
671 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
672
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
673 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
674 * Sets the designated parameter to the given Blob object. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
675 * converts this to an SQL BLOB value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
676 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
677 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
678 * @param x a Blob object that maps an SQL BLOB value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
679 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
680 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
681 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
682 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
683 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
684 public void setBlob(final int parameterIndex, final Blob x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
685 throw newSQLFeatureNotSupportedException("setBlob");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
686 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
687
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
688 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
689 * Sets the designated parameter to a InputStream object. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
690 * inputstream must contain the number of characters specified by
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
691 * length otherwise a SQLException will be generated when the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
692 * PreparedStatement is executed. This method differs from the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
693 * setBinaryStream (int, InputStream, int) method because it informs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
694 * the driver that the parameter value should be sent to the server
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
695 * as a BLOB. When the setBinaryStream method is used, the driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
696 * may have to do extra work to determine whether the parameter data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
697 * should be sent to the server as a LONGVARBINARY or a BLOB.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
698 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
699 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
700 * @param is an object that contains the data to set the parameter
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
701 * value to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
702 * @param length the number of bytes in the parameter data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
703 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
704 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
705 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
706 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
707 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
708 public void setBlob(final int parameterIndex, final InputStream is, final long length) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
709 throw newSQLFeatureNotSupportedException("setBlob");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
710 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
711
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
712 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
713 * Sets the designated parameter to the given Java boolean value. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
714 * driver converts this to an SQL BIT value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
715 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
716 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
717 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
718 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
719 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
720 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
721 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
722 public void setBoolean(final int parameterIndex, final boolean x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
723 setValue(parameterIndex, Boolean.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
724 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
725
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
726 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
727 * Sets the designated parameter to the given Java byte value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
728 * converts this to an SQL TINYINT value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
729 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
730 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
731 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
732 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
733 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
734 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
735 public void setByte(final int parameterIndex, final byte x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
736 setValue(parameterIndex, Byte.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
737 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
738
867
5a59910e8f87 Resolve some javadoc errors and warnings
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 833
diff changeset
739 private static final char[] HEXES = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
740 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
741 * Sets the designated parameter to the given Java array of bytes. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
742 * driver converts this to an SQL VARBINARY or LONGVARBINARY (depending
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
743 * on the argument's size relative to the driver's limits on VARBINARY
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
744 * values) when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
745 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
746 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
747 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
748 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
749 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
750 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
751 public void setBytes(final int parameterIndex, final byte[] x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
752 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
753 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
754 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
755 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
756
326
aa654804af6a Optimised setBytes() method. Eliminated the concatenation of 3 strings: "blob '" + hex.toString() + "'" which can be costly for large byte[] data, which has just been converted into hexString of twice its size.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 301
diff changeset
757 final int len = x.length;
aa654804af6a Optimised setBytes() method. Eliminated the concatenation of 3 strings: "blob '" + hex.toString() + "'" which can be costly for large byte[] data, which has just been converted into hexString of twice its size.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 301
diff changeset
758 final StringBuilder hex = new StringBuilder(8 + (len * 2));
aa654804af6a Optimised setBytes() method. Eliminated the concatenation of 3 strings: "blob '" + hex.toString() + "'" which can be costly for large byte[] data, which has just been converted into hexString of twice its size.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 301
diff changeset
759 hex.append("blob '"); // add a casting prefix
aa654804af6a Optimised setBytes() method. Eliminated the concatenation of 3 strings: "blob '" + hex.toString() + "'" which can be costly for large byte[] data, which has just been converted into hexString of twice its size.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 301
diff changeset
760 // convert the bytes into hex codes
aa654804af6a Optimised setBytes() method. Eliminated the concatenation of 3 strings: "blob '" + hex.toString() + "'" which can be costly for large byte[] data, which has just been converted into hexString of twice its size.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 301
diff changeset
761 for (int i = 0; i < len; i++) {
728
0a22044eee9c Optimize setBytes() implementation. For the 16 hex codes use a char[] and direct array indexing instead of a String and calling charAt().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 719
diff changeset
762 byte b = x[i];
0a22044eee9c Optimize setBytes() implementation. For the 16 hex codes use a char[] and direct array indexing instead of a String and calling charAt().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 719
diff changeset
763 hex.append(HEXES[(b & 0xF0) >> 4])
0a22044eee9c Optimize setBytes() implementation. For the 16 hex codes use a char[] and direct array indexing instead of a String and calling charAt().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 719
diff changeset
764 .append(HEXES[(b & 0x0F)]);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
765 }
890
7621c80b08da Optimise code, use append(char) instead of append(String)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 889
diff changeset
766 hex.append('\''); // end of hex string value
326
aa654804af6a Optimised setBytes() method. Eliminated the concatenation of 3 strings: "blob '" + hex.toString() + "'" which can be costly for large byte[] data, which has just been converted into hexString of twice its size.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 301
diff changeset
767 setValue(parameterIndex, hex.toString());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
768 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
769
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
770 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
771 * Sets the designated parameter to the given Reader object, which is the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
772 * given number of characters long. When a very large UNICODE value is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
773 * input to a LONGVARCHAR parameter, it may be more practical to send it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
774 * via a java.io.Reader object. The data will be read from the stream as
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
775 * needed until end-of-file is reached. The JDBC driver will do any
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
776 * necessary conversion from UNICODE to the database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
777 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
778 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
779 * your own subclass that implements the standard interface.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
780 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
781 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
782 * @param reader the java.io.Reader object that contains the Unicode data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
783 * @param length the number of characters in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
784 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
785 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
786 @Override
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
787 public void setCharacterStream(final int parameterIndex, final Reader reader, final int length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
788 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
789 {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
790 setClob(parameterIndex, reader, (long)length);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
791 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
792
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
793 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
794 * Sets the designated parameter to the given Reader object, which is the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
795 * given number of characters long. When a very large UNICODE value is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
796 * input to a LONGVARCHAR parameter, it may be more practical to send it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
797 * via a java.io.Reader object. The data will be read from the stream as
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
798 * needed until end-of-file is reached. The JDBC driver will do any
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
799 * necessary conversion from UNICODE to the database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
800 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
801 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
802 * your own subclass that implements the standard interface.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
803 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
804 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
805 * @param reader the java.io.Reader object that contains the Unicode data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
806 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
807 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
808 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
809 public void setCharacterStream(final int parameterIndex, final Reader reader)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
810 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
811 {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
812 setClob(parameterIndex, reader);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
813 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
814
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
815 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
816 * Sets the designated parameter to the given Reader object, which is the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
817 * given number of characters long. When a very large UNICODE value is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
818 * input to a LONGVARCHAR parameter, it may be more practical to send it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
819 * via a java.io.Reader object. The data will be read from the stream as
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
820 * needed until end-of-file is reached. The JDBC driver will do any
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
821 * necessary conversion from UNICODE to the database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
822 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
823 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
824 * your own subclass that implements the standard interface.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
825 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
826 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
827 * @param reader the java.io.Reader object that contains the Unicode data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
828 * @param length the number of characters in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
829 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
830 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
831 @Override
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
832 public void setCharacterStream(final int parameterIndex, final Reader reader, final long length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
833 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
834 {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
835 setClob(parameterIndex, reader, length);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
836 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
837
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
838 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
839 * Sets the designated parameter to the given Clob object. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
840 * converts this to an SQL CLOB value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
841 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
842 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
843 * @param x a Clob object that maps an SQL CLOB value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
844 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
845 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
846 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
847 public void setClob(final int parameterIndex, final Clob x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
848 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
849 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
850 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
851 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
852
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
853 // simply serialise the CLOB into a String for now... far from
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
854 // efficient, but might work for a few cases...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
855 // be on your marks: we have to cast the length down!
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
856 setString(parameterIndex, x.getSubString(1L, (int)(x.length())));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
857 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
858
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
859 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
860 * Sets the designated parameter to the given Clob object. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
861 * converts this to an SQL CLOB value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
862 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
863 * @param parameterIndex the first parameter is 1, the second is 2, ...
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
864 * @param reader an object that contains the data to set the parameter value to
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
865 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
866 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
867 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
868 public void setClob(final int parameterIndex, final Reader reader) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
869 if (reader == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
870 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
871 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
872 }
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
873
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
874 // Some buffer. Size of 8192 is default for BufferedReader, so...
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
875 final int size = 8192;
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
876 final char[] arr = new char[size];
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
877 final StringBuilder buf = new StringBuilder(size * 32);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
878 try {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
879 int numChars;
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
880 while ((numChars = reader.read(arr, 0, size)) > 0) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
881 buf.append(arr, 0, numChars);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
882 }
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
883 setString(parameterIndex, buf.toString());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
884 } catch (IOException e) {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
885 throw new SQLException("failed to read from stream: " + e.getMessage(), "M1M25");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
886 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
887 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
888
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
889 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
890 * Sets the designated parameter to a Reader object. The reader must
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
891 * contain the number of characters specified by length otherwise a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
892 * SQLException will be generated when the PreparedStatement is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
893 * executed. This method differs from the setCharacterStream (int,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
894 * Reader, int) method because it informs the driver that the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
895 * parameter value should be sent to the server as a CLOB. When the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
896 * setCharacterStream method is used, the driver may have to do
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
897 * extra work to determine whether the parameter data should be sent
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
898 * to the server as a LONGVARCHAR or a CLOB.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
899 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
900 * @param parameterIndex the first parameter is 1, the second is 2, ...
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
901 * @param reader An object that contains the data to set the parameter value to.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
902 * @param length the number of characters in the parameter data.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
903 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
904 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
905 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
906 public void setClob(final int parameterIndex, final Reader reader, final long length) throws SQLException {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
907 if (reader == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
908 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
909 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
910 }
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
911 if (length < 0 || length > Integer.MAX_VALUE) {
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
912 throw new SQLException("Invalid length value: " + length, "M1M05");
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
913 }
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
914
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
915 // simply serialise the Reader data into a large buffer
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
916 final CharBuffer buf = CharBuffer.allocate((int)length); // have to down cast
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
917 try {
815
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
918 long foo = 0;
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
919 while (foo < length) {
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
920 int n = reader.read(buf);
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
921 if (n < 0)
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
922 throw new SQLException("Stream ended unexpectedly at position " + foo + " out of " + length);
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
923 foo += n;
17b8a0a84e62 Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 773
diff changeset
924 }
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
925 // We have to rewind the buffer, because otherwise toString() returns "".
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
926 buf.rewind();
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
927 setString(parameterIndex, buf.toString());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
928 } catch (IOException e) {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
929 throw new SQLException("failed to read from stream: " + e.getMessage(), "M1M25");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
930 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
931 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
932
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
933 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
934 * Sets the designated parameter to the given java.sql.Date value. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
935 * driver converts this to an SQL DATE value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
936 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
937 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
938 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
939 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
940 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
941 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
942 @Override
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
943 public void setDate(final int parameterIndex, final Date x)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
944 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
945 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
946 setDate(parameterIndex, x, null);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
947 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
948
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
949 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
950 * Sets the designated parameter to the given java.sql.Date value, using
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
951 * the given Calendar object. The driver uses the Calendar object to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
952 * construct an SQL DATE value, which the driver then sends to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
953 * database. With a Calendar object, the driver can calculate the date
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
954 * taking into account a custom timezone. If no Calendar object is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
955 * specified, the driver uses the default timezone, which is that of the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
956 * virtual machine running the application.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
957 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
958 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
959 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
960 * @param cal the Calendar object the driver will use to construct the date
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
961 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
962 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
963 @Override
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
964 public void setDate(final int parameterIndex, final Date x, final Calendar cal)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
965 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
966 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
967 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
968 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
969 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
970 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
971
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
972 if (cal == null) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
973 setValue(parameterIndex, "date '" + x.toString() + "'");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
974 } else {
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
975 if (mDate == null) {
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
976 // first time usage, create and keep the mDate object for next usage
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
977 mDate = new SimpleDateFormat("yyyy-MM-dd");
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
978 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
979 mDate.setTimeZone(cal.getTimeZone());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
980 setValue(parameterIndex, "date '" + mDate.format(x) + "'");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
981 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
982 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
983
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
984 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
985 * Sets the designated parameter to the given Java double value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
986 * converts this to an SQL DOUBLE value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
987 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
988 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
989 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
990 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
991 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
992 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
993 public void setDouble(final int parameterIndex, final double x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
994 setValue(parameterIndex, Double.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
995 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
996
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
997 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
998 * Sets the designated parameter to the given Java float value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
999 * converts this to an SQL FLOAT value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1000 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1001 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1002 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1003 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1004 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1005 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1006 public void setFloat(final int parameterIndex, final float x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1007 setValue(parameterIndex, Float.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1008 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1009
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1010 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1011 * Sets the designated parameter to the given Java int value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1012 * converts this to an SQL INTEGER value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1013 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1014 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1015 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1016 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1017 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1018 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1019 public void setInt(final int parameterIndex, final int x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1020 setValue(parameterIndex, Integer.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1021 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1022
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1023 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1024 * Sets the designated parameter to the given Java long value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1025 * converts this to an SQL BIGINT value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1026 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1027 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1028 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1029 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1030 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1031 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1032 public void setLong(final int parameterIndex, final long x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1033 setValue(parameterIndex, Long.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1034 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1035
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1036 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1037 * Sets the designated parameter to a Reader object. The Reader
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1038 * reads the data till end-of-file is reached. The driver does the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1039 * necessary conversion from Java character format to the national
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1040 * character set in the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1041 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1042 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1043 * @param value the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1044 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1045 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1046 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1047 public void setNCharacterStream(final int parameterIndex, final Reader value) throws SQLException {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
1048 setCharacterStream(parameterIndex, value);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1049 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1050
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1051 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1052 * Sets the designated parameter to a Reader object. The Reader
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1053 * reads the data till end-of-file is reached. The driver does the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1054 * necessary conversion from Java character format to the national
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1055 * character set in the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1056 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1057 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1058 * @param value the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1059 * @param length the number of characters in the parameter data.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1060 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1061 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1062 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1063 public void setNCharacterStream(final int parameterIndex, final Reader value, final long length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1064 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1065 {
163
e398c27acf7e Implemented PreparedStatement methods setNCharacterStream(int, Reader) and setNCharacterStream(int, Reader, long).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 162
diff changeset
1066 setCharacterStream(parameterIndex, value, length);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1067 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1068
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1069 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1070 * Sets the designated parameter to a java.sql.NClob object. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1071 * driver converts this to a SQL NCLOB value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1072 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1073 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1074 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1075 * @param value the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1076 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1077 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1078 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1079 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1080 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1081 public void setNClob(final int parameterIndex, final Reader value) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1082 throw newSQLFeatureNotSupportedException("setNClob");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1083 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1084
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1085 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1086 * Sets the designated parameter to a java.sql.NClob object. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1087 * driver converts this to a SQL NCLOB value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1088 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1089 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1090 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1091 * @param value the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1092 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1093 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1094 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1095 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1096 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1097 public void setNClob(final int parameterIndex, final NClob value) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1098 throw newSQLFeatureNotSupportedException("setNClob");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1099 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1100
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1101 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1102 * Sets the designated parameter to a Reader object. The reader must
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1103 * contain the number of characters specified by length otherwise a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1104 * SQLException will be generated when the PreparedStatement is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1105 * executed. This method differs from the setCharacterStream (int,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1106 * Reader, int) method because it informs the driver that the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1107 * parameter value should be sent to the server as a NCLOB. When the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1108 * setCharacterStream method is used, the driver may have to do
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1109 * extra work to determine whether the parameter data should be sent
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1110 * to the server as a LONGNVARCHAR or a NCLOB.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1111 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1112 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1113 * @param r An object that contains the data to set the parameter
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1114 * value to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1115 * @param length the number of characters in the parameter data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1116 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1117 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1118 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1119 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1120 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1121 public void setNClob(final int parameterIndex, final Reader r, final long length) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1122 throw newSQLFeatureNotSupportedException("setNClob");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1123 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1124
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1125 /**
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
1126 * Sets the designated parameter to the given String object. The
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1127 * driver converts this to a SQL NCHAR or NVARCHAR or LONGNVARCHAR
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1128 * value (depending on the argument's size relative to the driver's
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1129 * limits on NVARCHAR values) when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1130 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1131 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1132 * @param value the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1133 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1134 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1135 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1136 public void setNString(final int parameterIndex, final String value) throws SQLException {
155
36f55bb8dd57 Implemented PreparedStatement method setNString().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 154
diff changeset
1137 setString(parameterIndex, value);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1138 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1139
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1140 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1141 * Sets the designated parameter to SQL NULL.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1142 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1143 * Note: You must specify the parameter's SQL type.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1144 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1145 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1146 * @param sqlType the SQL type code defined in java.sql.Types
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1147 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1148 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1149 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1150 public void setNull(final int parameterIndex, final int sqlType) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1151 // we discard the given type here, the backend converts the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1152 // value NULL to whatever it needs for the column
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1153 setValue(parameterIndex, "NULL");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1154 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1155
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1156 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1157 * Sets the designated parameter to SQL NULL. This version of the method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1158 * setNull should be used for user-defined types and REF type parameters.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1159 * Examples of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1160 * and named array types.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1161 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1162 * Note: To be portable, applications must give the SQL type code and the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1163 * fully-qualified SQL type name when specifying a NULL user-defined or REF
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1164 * parameter. In the case of a user-defined type the name is the type name
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1165 * of the parameter itself. For a REF parameter, the name is the type name
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1166 * of the referenced type. If a JDBC driver does not need the type code or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1167 * type name information, it may ignore it. Although it is intended for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1168 * user-defined and Ref parameters, this method may be used to set a null
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1169 * parameter of any JDBC type. If the parameter does not have a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1170 * user-defined or REF type, the given typeName is ignored.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1171 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1172 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1173 * @param sqlType a value from java.sql.Types
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1174 * @param typeName the fully-qualified name of an SQL user-defined type;
490
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
1175 * ignored if the parameter is not a user-defined type or REF
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1176 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1177 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1178 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1179 public void setNull(final int parameterIndex, final int sqlType, final String typeName)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1180 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1181 {
490
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
1182 // we discard the given type and name here, the backend converts the
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
1183 // value NULL to whatever it needs for the column
a6c98b35a054 Optimize setNull(3 args) method by doing the same thing as setNull(2 args)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 473
diff changeset
1184 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1185 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1186
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1187 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1188 * Sets the value of the designated parameter using the given
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1189 * object. The second parameter must be of type Object; therefore,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1190 * the java.lang equivalent objects should be used for built-in
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1191 * types.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1192 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1193 * The JDBC specification specifies a standard mapping from Java
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1194 * Object types to SQL types. The given argument will be converted
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1195 * to the corresponding SQL type before being sent to the database.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1196 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1197 * Note that this method may be used to pass datatabase-specific
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1198 * abstract data types, by using a driver-specific Java type. If the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1199 * object is of a class implementing the interface SQLData, the JDBC
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1200 * driver should call the method SQLData.writeSQL to write it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1201 * SQL data stream. If, on the other hand, the object is of a class
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1202 * implementing Ref, Blob, Clob, Struct, or Array, the driver should
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1203 * pass it to the database as a value of the corresponding SQL type.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1204 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1205 * This method throws an exception if there is an ambiguity, for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1206 * example, if the object is of a class implementing more than one
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1207 * of the interfaces named above.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1208 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1209 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1210 * @param x the object containing the input parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1211 * @throws SQLException if a database access error occurs or the type of
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1212 * the given object is ambiguous
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1213 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1214 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1215 public void setObject(final int parameterIndex, final Object x) throws SQLException {
157
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1216 setObject(parameterIndex, x, javaType[getParamIdx(parameterIndex)], 0);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1217 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1218
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1219 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1220 * Sets the value of the designated parameter with the given object. This
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1221 * method is like the method setObject below, except that it assumes a scale
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1222 * of zero.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1223 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1224 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1225 * @param x the object containing the input parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1226 * @param targetSqlType the SQL type (as defined in java.sql.Types) to be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1227 * sent to the database
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1228 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1229 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1230 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1231 public void setObject(final int parameterIndex, final Object x, final int targetSqlType)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1232 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1233 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1234 setObject(parameterIndex, x, targetSqlType, 0);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1235 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1236
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1237 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1238 * Sets the value of the designated parameter with the given object. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1239 * second argument must be an object type; for integral values, the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1240 * java.lang equivalent objects should be used.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1241 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1242 * The given Java object will be converted to the given targetSqlType
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1243 * before being sent to the database. If the object has a custom mapping
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1244 * (is of a class implementing the interface SQLData), the JDBC driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1245 * should call the method SQLData.writeSQL to write it to the SQL data
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1246 * stream. If, on the other hand, the object is of a class implementing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1247 * Ref, Blob, Clob, Struct, or Array, the driver should pass it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1248 * database as a value of the corresponding SQL type.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1249 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1250 * Note that this method may be used to pass database-specific abstract
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1251 * data types.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1252 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1253 * To meet the requirements of this interface, the Java object is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1254 * converted in the driver, instead of using a SQL CAST construct.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1255 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1256 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1257 * @param x the object containing the input parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1258 * @param targetSqlType the SQL type (as defined in java.sql.Types) to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1259 * be sent to the database. The scale argument may
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1260 * further qualify this type.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1261 * @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1262 * this is the number of digits after the decimal
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1263 * point. For Java Object types InputStream and Reader,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1264 * this is the length of the data in the stream or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1265 * reader. For all other types, this value will be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1266 * ignored.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1267 * @throws SQLException if a database access error occurs
262
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
1268 * @throws SQLFeatureNotSupportedException the JDBC driver does
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
1269 * not support this method
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1270 * @see Types
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1271 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1272 @Override
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
1273 public void setObject(final int parameterIndex, final Object x, final int targetSqlType, final int scale)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1274 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1275 {
157
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1276 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
1277 setValue(parameterIndex, "NULL");
157
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1278 return;
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1279 }
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1280
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1281 // this is according to table B-5
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1282 if (x instanceof String) {
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1283 setString(parameterIndex, (String)x);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1284 } else if (x instanceof BigDecimal ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1285 x instanceof Byte ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1286 x instanceof Short ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1287 x instanceof Integer ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1288 x instanceof Long ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1289 x instanceof Float ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1290 x instanceof Double)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1291 {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1292 final Number num = (Number)x;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1293 switch (targetSqlType) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1294 case Types.TINYINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1295 setByte(parameterIndex, num.byteValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1296 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1297 case Types.SMALLINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1298 setShort(parameterIndex, num.shortValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1299 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1300 case Types.INTEGER:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1301 setInt(parameterIndex, num.intValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1302 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1303 case Types.BIGINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1304 if (x instanceof BigDecimal) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1305 BigDecimal bd = (BigDecimal)x;
301
59bc8bebbfe9 Resolve javac -Xlint warnings when compiled on Java 9 or higher
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 295
diff changeset
1306 setLong(parameterIndex, bd.setScale(scale, java.math.RoundingMode.HALF_UP).longValue());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1307 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1308 setLong(parameterIndex, num.longValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1309 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1310 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1311 case Types.REAL:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1312 setFloat(parameterIndex, num.floatValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1313 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1314 case Types.FLOAT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1315 case Types.DOUBLE:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1316 setDouble(parameterIndex, num.doubleValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1317 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1318 case Types.DECIMAL:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1319 case Types.NUMERIC:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1320 if (x instanceof BigDecimal) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1321 setBigDecimal(parameterIndex, (BigDecimal)x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1322 } else {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
1323 setBigDecimal(parameterIndex, new BigDecimal(num.doubleValue()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1324 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1325 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1326 case Types.BOOLEAN:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1327 if (num.doubleValue() != 0.0) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1328 setBoolean(parameterIndex, true);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1329 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1330 setBoolean(parameterIndex, false);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1331 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1332 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1333 case Types.CHAR:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1334 case Types.VARCHAR:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1335 case Types.LONGVARCHAR:
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1336 case Types.CLOB:
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1337 setString(parameterIndex, x.toString());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1338 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1339 default:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1340 throw new SQLException("Conversion not allowed", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1341 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1342 } else if (x instanceof Boolean) {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1343 final boolean val = ((Boolean)x).booleanValue();
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1344 switch (targetSqlType) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1345 case Types.TINYINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1346 setByte(parameterIndex, (byte)(val ? 1 : 0));
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1347 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1348 case Types.SMALLINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1349 setShort(parameterIndex, (short)(val ? 1 : 0));
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1350 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1351 case Types.INTEGER:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1352 setInt(parameterIndex, (val ? 1 : 0)); // do not cast to (int) as it generates a compiler warning
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1353 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1354 case Types.BIGINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1355 setLong(parameterIndex, (long)(val ? 1 : 0));
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1356 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1357 case Types.REAL:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1358 setFloat(parameterIndex, (float)(val ? 1.0 : 0.0));
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1359 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1360 case Types.FLOAT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1361 case Types.DOUBLE:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1362 setDouble(parameterIndex, (val ? 1.0 : 0.0)); // do no cast to (double) as it generates a compiler warning
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1363 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1364 case Types.DECIMAL:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1365 case Types.NUMERIC:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1366 {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1367 final BigDecimal dec;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1368 try {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1369 dec = new BigDecimal(val ? 1.0 : 0.0);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1370 } catch (NumberFormatException e) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1371 throw new SQLException("Internal error: unable to create template BigDecimal: " + e.getMessage(), "M0M03");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1372 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1373 setBigDecimal(parameterIndex, dec);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1374 } break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1375 case Types.BOOLEAN:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1376 setBoolean(parameterIndex, val);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1377 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1378 case Types.CHAR:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1379 case Types.VARCHAR:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1380 case Types.LONGVARCHAR:
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1381 case Types.CLOB:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1382 setString(parameterIndex, x.toString());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1383 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1384 default:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1385 throw new SQLException("Conversion not allowed", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1386 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1387 } else if (x instanceof BigInteger) {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1388 final BigInteger num = (BigInteger)x;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1389 switch (targetSqlType) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1390 case Types.BIGINT:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1391 setLong(parameterIndex, num.longValue());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1392 break;
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1393 case Types.DECIMAL:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1394 case Types.NUMERIC:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1395 {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1396 final BigDecimal dec;
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1397 try {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1398 dec = new BigDecimal(num);
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1399 } catch (NumberFormatException e) {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1400 throw new SQLException("Internal error: unable to create template BigDecimal: " + e.getMessage(), "M0M03");
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1401 }
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1402 setBigDecimal(parameterIndex, dec);
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1403 } break;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1404 case Types.CHAR:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1405 case Types.VARCHAR:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1406 case Types.LONGVARCHAR:
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1407 case Types.CLOB:
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1408 setString(parameterIndex, x.toString());
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1409 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1410 default:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1411 throw new SQLException("Conversion not allowed", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1412 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1413 } else if (x instanceof byte[]) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1414 switch (targetSqlType) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1415 case Types.BINARY:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1416 case Types.VARBINARY:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1417 case Types.LONGVARBINARY:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1418 setBytes(parameterIndex, (byte[])x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1419 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1420 default:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1421 throw new SQLException("Conversion not allowed", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1422 }
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1423 } else if (x instanceof Date ||
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1424 x instanceof Timestamp ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1425 x instanceof Time ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1426 x instanceof Calendar ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1427 x instanceof java.util.Date)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1428 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1429 switch (targetSqlType) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1430 case Types.DATE:
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1431 if (x instanceof Date) {
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1432 setDate(parameterIndex, (Date)x);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1433 } else if (x instanceof Timestamp) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1434 setDate(parameterIndex, new Date(((Timestamp)x).getTime()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1435 } else if (x instanceof java.util.Date) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1436 setDate(parameterIndex, new Date(((java.util.Date)x).getTime()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1437 } else if (x instanceof Calendar) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1438 setDate(parameterIndex, new Date(((Calendar)x).getTimeInMillis()));
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1439 } else {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1440 throw new SQLException("Conversion not allowed", "M1M05");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1441 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1442 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1443 case Types.TIME:
380
bf521f343172 Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1444 case Types.TIME_WITH_TIMEZONE:
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1445 if (x instanceof Time) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1446 setTime(parameterIndex, (Time)x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1447 } else if (x instanceof Timestamp) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1448 setTime(parameterIndex, new Time(((Timestamp)x).getTime()));
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1449 } else if (x instanceof java.util.Date) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1450 setTime(parameterIndex, new Time(((java.util.Date)x).getTime()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1451 } else if (x instanceof Calendar) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1452 setTime(parameterIndex, new Time(((Calendar)x).getTimeInMillis()));
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1453 } else {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1454 throw new SQLException("Conversion not allowed", "M1M05");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1455 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1456 break;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1457 case Types.TIMESTAMP:
380
bf521f343172 Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1458 case Types.TIMESTAMP_WITH_TIMEZONE:
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1459 if (x instanceof Timestamp) {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1460 setTimestamp(parameterIndex, (Timestamp)x);
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1461 } else if (x instanceof Date) {
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1462 setTimestamp(parameterIndex, new Timestamp(((Date)x).getTime()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1463 } else if (x instanceof java.util.Date) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1464 setTimestamp(parameterIndex, new Timestamp(((java.util.Date)x).getTime()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1465 } else if (x instanceof Calendar) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1466 setTimestamp(parameterIndex, new Timestamp(((Calendar)x).getTimeInMillis()));
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1467 } else {
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1468 throw new SQLException("Conversion not allowed", "M1M05");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1469 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1470 break;
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1471 case Types.CHAR:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1472 case Types.VARCHAR:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1473 case Types.LONGVARCHAR:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1474 case Types.CLOB:
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1475 setString(parameterIndex, x.toString());
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1476 break;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1477 default:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1478 throw new SQLException("Conversion not allowed", "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1479 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1480 } else if (x instanceof Array) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1481 setArray(parameterIndex, (Array)x);
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1482 } else if (x instanceof MonetBlob || x instanceof Blob) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1483 setBlob(parameterIndex, (Blob)x);
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1484 } else if (x instanceof MonetClob || x instanceof Clob) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1485 setClob(parameterIndex, (Clob)x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1486 } else if (x instanceof Ref) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1487 setRef(parameterIndex, (Ref)x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1488 } else if (x instanceof java.net.URL) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1489 setURL(parameterIndex, (java.net.URL)x);
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1490 } else if (x instanceof java.util.UUID) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1491 setString(parameterIndex, x.toString());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1492 } else if (x instanceof RowId) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1493 setRowId(parameterIndex, (RowId)x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1494 } else if (x instanceof NClob) {
157
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1495 setNClob(parameterIndex, (NClob)x);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1496 } else if (x instanceof SQLXML) {
157
9ce094bd1bff Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 156
diff changeset
1497 setSQLXML(parameterIndex, (SQLXML)x);
683
79f246478ca8 For a Class object use getCanonicalName() instead of getName().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 682
diff changeset
1498 } else if (x instanceof SQLData) {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1499 final SQLData sx = (SQLData)x;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1500 final int paramnr = parameterIndex;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1501 final String sqltype = sx.getSQLTypeName();
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1502 final SQLOutput out = new SQLOutput() {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1503 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1504 public void writeString(String x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1505 // special situation, this is when a string
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1506 // representation is given, but we need to prefix it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1507 // with the actual sqltype the server expects, or we
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1508 // will get an error back
425
95d15f1d750d Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
1509 setValue(paramnr, sqltype + " " + MonetWrapper.sq(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1510 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1511
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1512 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1513 public void writeBoolean(boolean x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1514 setBoolean(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1515 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1516
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1517 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1518 public void writeByte(byte x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1519 setByte(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1520 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1521
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1522 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1523 public void writeShort(short x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1524 setShort(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1525 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1526
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1527 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1528 public void writeInt(int x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1529 setInt(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1530 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1531
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1532 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1533 public void writeLong(long x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1534 setLong(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1535 }
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 25
diff changeset
1536
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1537 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1538 public void writeFloat(float x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1539 setFloat(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1540 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1541
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1542 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1543 public void writeDouble(double x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1544 setDouble(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1545 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1546
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1547 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1548 public void writeBigDecimal(BigDecimal x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1549 setBigDecimal(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1550 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1551
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1552 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1553 public void writeBytes(byte[] x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1554 setBytes(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1555 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1556
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1557 @Override
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1558 public void writeDate(Date x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1559 setDate(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1560 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1561
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1562 @Override
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1563 public void writeTime(Time x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1564 setTime(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1565 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1566
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1567 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1568 public void writeTimestamp(Timestamp x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1569 setTimestamp(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1570 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1571
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1572 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1573 public void writeCharacterStream(Reader x) throws SQLException {
328
65bf0be846f3 Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 326
diff changeset
1574 setCharacterStream(paramnr, x);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1575 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1576
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1577 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1578 public void writeAsciiStream(InputStream x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1579 setAsciiStream(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1580 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1581
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1582 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1583 public void writeBinaryStream(InputStream x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1584 setBinaryStream(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1585 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1586
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1587 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1588 public void writeObject(SQLData x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1589 setObject(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1590 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1591
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1592 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1593 public void writeRef(Ref x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1594 setRef(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1595 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1596
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1597 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1598 public void writeBlob(Blob x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1599 setBlob(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1600 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1601
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1602 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1603 public void writeClob(Clob x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1604 setClob(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1605 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1606
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1607 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1608 public void writeStruct(Struct x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1609 setObject(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1610 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1611
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1612 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1613 public void writeArray(Array x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1614 setArray(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1615 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1616
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1617 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1618 public void writeURL(URL x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1619 setURL(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1620 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1621
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1622 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1623 public void writeNString(String x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1624 setNString(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1625 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1626
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1627 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1628 public void writeNClob(NClob x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1629 setNClob(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1630 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1631
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1632 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1633 public void writeRowId(RowId x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1634 setRowId(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1635 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1636
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1637 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1638 public void writeSQLXML(SQLXML x) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1639 setSQLXML(paramnr, x);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1640 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1641 };
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1642 sx.writeSQL(out);
683
79f246478ca8 For a Class object use getCanonicalName() instead of getName().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 682
diff changeset
1643 } else if (x instanceof Struct) {
79f246478ca8 For a Class object use getCanonicalName() instead of getName().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 682
diff changeset
1644 // I have no idea how to do this...
79f246478ca8 For a Class object use getCanonicalName() instead of getName().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 682
diff changeset
1645 throw newSQLFeatureNotSupportedException("setObject() with object of type Struct");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1646 } else { // java Class
683
79f246478ca8 For a Class object use getCanonicalName() instead of getName().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 682
diff changeset
1647 throw newSQLFeatureNotSupportedException("setObject() with object of type Class " + x.getClass().getCanonicalName());
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1648 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1649 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1650
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1651 /**
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 186
diff changeset
1652 * Sets the designated parameter to the given REF(&lt;structured-type&gt;) value.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1653 * The driver converts this to an SQL REF value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1654 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1655 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1656 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1657 * @param x an SQL REF value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1658 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1659 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1660 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1661 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1662 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1663 public void setRef(final int parameterIndex, final Ref x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1664 throw newSQLFeatureNotSupportedException("setRef");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1665 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1666
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1667 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1668 * Sets the designated parameter to the given java.sql.RowId object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1669 * The driver converts this to a SQL ROWID value when it sends it to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1670 * the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1671 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1672 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1673 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1674 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1675 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1676 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1677 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1678 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1679 public void setRowId(final int parameterIndex, final RowId x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1680 throw newSQLFeatureNotSupportedException("setRowId");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1681 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1682
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1683 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1684 * Sets the designated parameter to the given Java short value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1685 * converts this to an SQL SMALLINT value when it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1686 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1687 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1688 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1689 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1690 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1691 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1692 public void setShort(final int parameterIndex, final short x) throws SQLException {
131
0112d8496636 Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
1693 setValue(parameterIndex, Short.toString(x));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1694 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1695
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1696 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1697 * Sets the designated parameter to the given Java String value. The driver
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1698 * converts this to an SQL VARCHAR or LONGVARCHAR value (depending on the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1699 * argument's size relative to the driver's limits on VARCHAR values) when
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1700 * it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1701 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1702 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1703 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1704 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1705 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1706 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1707 public void setString(final int parameterIndex, final String x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1708 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
1709 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1710 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1711 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1712
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1713 final int paramIdx = getParamIdx(parameterIndex); // this will throw a SQLException if parameter can not be found
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1714
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1715 /* depending on the parameter data type (as expected by MonetDB) we
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1716 may need to add the data type as cast prefix to the parameter value */
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1717 final int paramJdbcType = javaType[paramIdx];
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1718 final String paramMonetdbType = monetdbType[paramIdx];
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1719
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1720 switch (paramJdbcType) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1721 case Types.CHAR:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1722 case Types.VARCHAR:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1723 case Types.LONGVARCHAR:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1724 case Types.CLOB:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1725 case Types.NCHAR:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1726 case Types.NVARCHAR:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1727 case Types.LONGNVARCHAR:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1728 {
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1729 String castprefix = null;
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1730 switch (paramMonetdbType) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1731 // some MonetDB specific data types require a cast prefix
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1732 case "inet":
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1733 try {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1734 // check if x represents a valid inet string to prevent
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1735 // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351
391
f523727db392 Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 382
diff changeset
1736 org.monetdb.jdbc.types.INET inet_obj = new org.monetdb.jdbc.types.INET();
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1737 inet_obj.fromString(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1738 } catch (SQLException se) {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1739 throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed. " + se.getMessage(), "22M29");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1740 }
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1741 castprefix = "inet ";
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1742 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1743 case "json":
436
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1744 {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1745 // do a quick JSON string validity check to prevent failing exec #(..., ...) calls
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1746 // which destroy the prepared statement(s), see bug 6351 and 6832
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1747 String conversionIssue = null;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1748 if (x.isEmpty()) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1749 conversionIssue = "It may not be empty";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1750 } else {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1751 // scan for first and last non-whitespace character
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1752 int start = 0;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1753 int end = x.length() -1;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1754 // find first non white space character
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1755 char firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1756 while ((firstc == ' ' || firstc == '\t' || firstc == '\n' || firstc == '\r')
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1757 && (start < end)) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1758 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1759 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1760 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1761 // find last non white space character
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1762 char lastc = x.charAt(end);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1763 while ((lastc == ' ' || lastc == '\t' || lastc == '\n' || lastc == '\r')
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1764 && (start < end)) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1765 end--;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1766 lastc = x.charAt(end);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1767 }
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1768
436
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1769 if (end - start <= 0) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1770 conversionIssue = "It may not be empty";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1771 } else {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1772 switch (firstc) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1773 case '{': // start of an object
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1774 if (lastc != '}')
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1775 conversionIssue = "It does not end with }";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1776 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1777 case '[': // start of an array
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1778 if (lastc != ']')
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1779 conversionIssue = "It does not end with ]";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1780 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1781 case '"': // start of a string
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1782 if (lastc != '"')
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1783 conversionIssue = "It does not end with \"";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1784 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1785 case 'n': // start of literal: null
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1786 if (lastc != 'l' || (end - start != 3) || !"null".equals(x.trim()))
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1787 conversionIssue = "It does not match: null";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1788 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1789 case 'f': // start of literal: false
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1790 if (lastc != 'e' || (end - start != 4) || !"false".equals(x.trim()))
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1791 conversionIssue = "It does not match: false";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1792 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1793 case 't': // start of literal: true
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1794 if (lastc != 'e' || (end - start != 3) || !"true".equals(x.trim()))
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1795 conversionIssue = "It does not match: true";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1796 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1797 case '-': // start of a number with a negative sign
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1798 case '+': // start of a number with a positive sign
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1799 case '0':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1800 case '1':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1801 case '2':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1802 case '3':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1803 case '4':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1804 case '5':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1805 case '6':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1806 case '7':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1807 case '8':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1808 case '9':
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1809 // start of a number in format: [ - | + ] int [ frac ] [ exp ]
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1810 // check if it continues with more digits
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1811 if (start < end)
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1812 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1813 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1814 while (firstc >= '0' && firstc <= '9' && start < end) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1815 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1816 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1817 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1818 // check if it continues with optional fractions
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1819 if (firstc == '.' && start < end) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1820 // yes, consume the digits of the fraction
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1821 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1822 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1823 while (firstc >= '0' && firstc <= '9' && start < end) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1824 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1825 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1826 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1827 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1828 // check if it continues with optional exponent
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1829 if ((firstc == 'E' || firstc == 'e') && start < end) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1830 // yes, consume the optional sign
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1831 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1832 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1833 if ((firstc == '+' || firstc == '-') && start < end) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1834 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1835 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1836 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1837 // yes, consume the digits of the exponnent
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1838 while ((firstc >= '0' && firstc <= '9') && start < end) {
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1839 start++;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1840 firstc = x.charAt(start);
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1841 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1842 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1843 if (start != end)
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1844 conversionIssue = "It does not represent a valid number";
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1845 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1846 default:
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1847 conversionIssue = "Invalid first character: " + firstc;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1848 break;
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1849 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1850 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1851 }
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1852 if (conversionIssue != null)
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1853 throw new SQLDataException("Invalid json string. " + conversionIssue, "22M32");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1854
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1855 castprefix = "json ";
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1856 break;
436
b32946647c77 Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 426
diff changeset
1857 }
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1858 case "url":
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1859 try {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1860 // also check if x represents a valid url string to prevent
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1861 // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351
769
b6d113ee35ae Fixed javac version 20 compiler warnings.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 728
diff changeset
1862 // Note: as of Java version 20 java.net.URL(String) constructor is deprecated.
b6d113ee35ae Fixed javac version 20 compiler warnings.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 728
diff changeset
1863 // https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/net/URL.html#%3Cinit%3E(java.lang.String)
b6d113ee35ae Fixed javac version 20 compiler warnings.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 728
diff changeset
1864 java.net.URL url_obj = new java.net.URI(x).toURL();
b6d113ee35ae Fixed javac version 20 compiler warnings.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 728
diff changeset
1865 } catch (java.net.URISyntaxException | java.net.MalformedURLException mue) {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1866 throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed. " + mue.getMessage(), "22M30");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1867 }
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1868 castprefix = "url ";
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1869 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1870 case "uuid":
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1871 try {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1872 // also check if x represents a valid uuid string to prevent
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1873 // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1874 java.util.UUID uuid_obj = java.util.UUID.fromString(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1875 } catch (IllegalArgumentException iae) {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1876 throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed. " + iae.getMessage(), "22M31");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1877 }
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1878 castprefix = "uuid ";
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1879 break;
642
dd9b4fb14256 Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 624
diff changeset
1880 // case "xml":
dd9b4fb14256 Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 624
diff changeset
1881 // currently any string is accepted by MonetDB, so no validity check needed
dd9b4fb14256 Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 624
diff changeset
1882 // castprefix = "xml "; also do NOT add a cast as MonetDB implicitly already converts a String to an xml String
dd9b4fb14256 Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 624
diff changeset
1883 // break;
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1884 }
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1885 if (castprefix != null) {
642
dd9b4fb14256 Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 624
diff changeset
1886 /* in specific cases prefix the string with: inet or json or url or uuid or xml casting */
426
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1887 setValue(parameterIndex, castprefix + MonetWrapper.sq(x));
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1888 } else {
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1889 setValue(parameterIndex, MonetWrapper.sq(x));
3da79315783b Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 425
diff changeset
1890 }
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1891 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1892 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1893 case Types.TINYINT:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1894 case Types.SMALLINT:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1895 case Types.INTEGER:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1896 case Types.BIGINT:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1897 case Types.REAL:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1898 case Types.FLOAT:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1899 case Types.DOUBLE:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1900 case Types.DECIMAL:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1901 case Types.NUMERIC:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1902 try {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1903 // check (by calling parse) if the string represents a valid number to prevent
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1904 // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1905 if (paramJdbcType == Types.INTEGER || paramJdbcType == Types.SMALLINT || paramJdbcType == Types.TINYINT) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1906 int number = Integer.parseInt(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1907 } else
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1908 if (paramJdbcType == Types.BIGINT) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1909 long number = Long.parseLong(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1910 } else
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1911 if (paramJdbcType == Types.REAL || paramJdbcType == Types.DOUBLE || paramJdbcType == Types.FLOAT) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1912 double number = Double.parseDouble(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1913 } else
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1914 if (paramJdbcType == Types.DECIMAL || paramJdbcType == Types.NUMERIC) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1915 BigDecimal number = new BigDecimal(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1916 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1917 } catch (NumberFormatException nfe) {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1918 throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed. " + nfe.getMessage(), "22003");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1919 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1920 setValue(parameterIndex, x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1921 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1922 case Types.BOOLEAN:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1923 if (x.equalsIgnoreCase("false") || x.equalsIgnoreCase("true") || x.equals("0") || x.equals("1")) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1924 setValue(parameterIndex, x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1925 } else {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1926 throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed", "22000");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1927 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1928 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1929 case Types.DATE:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1930 case Types.TIME:
380
bf521f343172 Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1931 case Types.TIME_WITH_TIMEZONE:
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1932 case Types.TIMESTAMP:
380
bf521f343172 Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1933 case Types.TIMESTAMP_WITH_TIMEZONE:
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1934 try {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1935 // check if the string represents a valid calendar date or time or timestamp to prevent
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1936 // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1937 if (paramJdbcType == Types.DATE) {
773
2bd1983f1c11 Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 769
diff changeset
1938 Date datum = Date.valueOf(x);
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1939 } else
380
bf521f343172 Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1940 if (paramJdbcType == Types.TIME || paramJdbcType == Types.TIME_WITH_TIMEZONE) {
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1941 Time tijdstip = Time.valueOf(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1942 } else
380
bf521f343172 Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1943 if (paramJdbcType == Types.TIMESTAMP || paramJdbcType == Types.TIMESTAMP_WITH_TIMEZONE) {
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1944 Timestamp tijdstip = Timestamp.valueOf(x);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1945 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1946 } catch (IllegalArgumentException iae) {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1947 throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed. " + iae.getMessage(), "22007");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1948 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1949 /* prefix the string with: date or time or timetz or timestamp or timestamptz */
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1950 setValue(parameterIndex, paramMonetdbType + " '" + x + "'");
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1951 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1952 case Types.BINARY:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1953 case Types.VARBINARY:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1954 case Types.LONGVARBINARY:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1955 case Types.BLOB:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1956 // check if the string x contains pairs of hex chars to prevent
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1957 // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1958 final int xlen = x.length();
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1959 for (int i = 0; i < xlen; i++) {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1960 char c = x.charAt(i);
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1961 if (c < '0' || c > '9') {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1962 if (c < 'A' || c > 'F') {
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1963 if (c < 'a' || c > 'f') {
166
5c575fb21be0 Improve thrown SQLExceptions in setString(), changed them into SQLDataException with distinct SQLState codes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 165
diff changeset
1964 throw new SQLDataException("Invalid string for parameter data type " + paramMonetdbType + ". The string may contain only hex chars", "22M28");
159
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1965 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1966 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1967 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1968 }
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1969 /* prefix the string with: blob */
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1970 setValue(parameterIndex, "blob '" + x + "'");
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1971 break;
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1972 default:
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1973 throw new SQLException("Conversion of string to parameter data type " + paramMonetdbType + " is not (yet) supported", "M1M05");
8ea360b612de Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 157
diff changeset
1974 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1975 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1976
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1977 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1978 * Sets the designated parameter to the given java.sql.SQLXML
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1979 * object. The driver converts this to an SQL XML value when it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1980 * sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1981 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1982 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1983 * @param x a SQLXML object that maps an SQL XML value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1984 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1985 * @throws SQLFeatureNotSupportedException the JDBC driver does
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1986 * not support this method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1987 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1988 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1989 public void setSQLXML(final int parameterIndex, final SQLXML x) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1990 throw newSQLFeatureNotSupportedException("setSQLXML");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1991 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1992
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1993 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1994 * Sets the designated parameter to the given java.sql.Time value.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1995 * The driver converts this to an SQL TIME value when it sends it to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1996 * the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1997 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
1998 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1999 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2000 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2001 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2002 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2003 public void setTime(final int parameterIndex, final Time x) throws SQLException {
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2004 setTime(parameterIndex, x, null);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2005 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2006
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2007 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2008 * Sets the designated parameter to the given java.sql.Time value,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2009 * using the given Calendar object. The driver uses the Calendar
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2010 * object to construct an SQL TIME value, which the driver then
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2011 * sends to the database. With a Calendar object, the driver can
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2012 * calculate the time taking into account a custom timezone. If no
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2013 * Calendar object is specified, the driver uses the default
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2014 * timezone, which is that of the virtual machine running the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2015 * application.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2016 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2017 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2018 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2019 * @param cal the Calendar object the driver will use to construct the time
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2020 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2021 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2022 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2023 public void setTime(final int parameterIndex, final Time x, final Calendar cal)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2024 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2025 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2026 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2027 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2028 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2029 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2030
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2031 final String MonetDBType = monetdbType[getParamIdx(parameterIndex)];
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2032 final boolean hasTimeZone = ("timetz".equals(MonetDBType) || "timestamptz".equals(MonetDBType));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2033 if (hasTimeZone) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2034 // timezone shouldn't matter, since the server is timezone
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2035 // aware in this case
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2036 if (mTimeZ == null) {
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2037 // first time usage, create and keep the mTimeZ object for next usage
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2038 mTimeZ = new SimpleDateFormat("HH:mm:ss.SSSZ");
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2039 }
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2040 final String RFC822 = mTimeZ.format(x);
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2041 setValue(parameterIndex, "timetz '" + RFC822.substring(0, 15) + ":" + RFC822.substring(15) + "'");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2042 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2043 // server is not timezone aware for this field, and no
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2044 // calendar given, since we told the server our timezone at
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2045 // connection creation, we can just write a plain timestamp
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2046 // here
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2047 if (cal == null) {
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2048 setValue(parameterIndex, "time '" + x.toString() + "'");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2049 } else {
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2050 if (mTime == null) {
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2051 // first time usage, create and keep the mTime object for next usage
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2052 mTime = new SimpleDateFormat("HH:mm:ss.SSS");
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2053 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2054 mTime.setTimeZone(cal.getTimeZone());
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2055 setValue(parameterIndex, "time '" + mTime.format(x) + "'");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2056 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2057 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2058 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2059
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2060 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2061 * Sets the designated parameter to the given java.sql.Timestamp
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2062 * value. The driver converts this to an SQL TIMESTAMP value when
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2063 * it sends it to the database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2064 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2065 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2066 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2067 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2068 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2069 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2070 public void setTimestamp(final int parameterIndex, final Timestamp x)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2071 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2072 {
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2073 setTimestamp(parameterIndex, x, null);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2074 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2075
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2076 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2077 * Sets the designated parameter to the given java.sql.Timestamp
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2078 * value, using the given Calendar object. The driver uses the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2079 * Calendar object to construct an SQL TIMESTAMP value, which the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2080 * driver then sends to the database. With a Calendar object, the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2081 * driver can calculate the timestamp taking into account a custom
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2082 * timezone. If no Calendar object is specified, the driver uses the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2083 * default timezone, which is that of the virtual machine running
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2084 * the application.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2085 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2086 * @param parameterIndex the first parameter is 1, the second is 2, ...
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2087 * @param x the parameter value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2088 * @param cal the Calendar object the driver will use to construct the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2089 * timestamp
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2090 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2091 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2092 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2093 public void setTimestamp(final int parameterIndex, final Timestamp x, final Calendar cal)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2094 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2095 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2096 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2097 setValue(parameterIndex, "NULL");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2098 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2099 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2100
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2101 final String MonetDBType = monetdbType[getParamIdx(parameterIndex)];
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2102 final boolean hasTimeZone = ("timestamptz".equals(MonetDBType) || "timetz".equals(MonetDBType));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2103 if (hasTimeZone) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2104 // timezone shouldn't matter, since the server is timezone
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2105 // aware in this case
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2106 if (mTimestampZ == null) {
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2107 // first time usage, create and keep the mTimestampZ object for next usage
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2108 mTimestampZ = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2109 }
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2110 final String RFC822 = mTimestampZ.format(x);
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2111 setValue(parameterIndex, "timestamptz '" + RFC822.substring(0, 26) + ":" + RFC822.substring(26) + "'");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2112 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2113 // server is not timezone aware for this field, and no
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2114 // calendar given, since we told the server our timezone at
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2115 // connection creation, we can just write a plain timestamp here
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2116 if (cal == null) {
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2117 setValue(parameterIndex, "timestamp '" + x.toString() + "'");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2118 } else {
161
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2119 if (mTimestamp == null) {
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2120 // first time usage, create and keep the mTimestamp object for next usage
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2121 mTimestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
6fd18d4cfa41 Delay the creation of five helper SimpleDateFormat objects for each PreparedStatement object
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 160
diff changeset
2122 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2123 mTimestamp.setTimeZone(cal.getTimeZone());
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2124 setValue(parameterIndex, "timestamp '" + mTimestamp.format(x) + "'");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2125 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2126 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2127 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2128
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2129 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2130 * Sets the designated parameter to the given input stream, which will have
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2131 * the specified number of bytes. A Unicode character has two bytes, with
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2132 * the first byte being the high byte, and the second being the low byte.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2133 * When a very large Unicode value is input to a LONGVARCHAR parameter, it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2134 * may be more practical to send it via a java.io.InputStream object. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2135 * data will be read from the stream as needed until end-of-file is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2136 * reached. The JDBC driver will do any necessary conversion from Unicode
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2137 * to the database char format.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
2138 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2139 * Note: This stream object can either be a standard Java stream object or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2140 * your own subclass that implements the standard interface.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2141 *
301
59bc8bebbfe9 Resolve javac -Xlint warnings when compiled on Java 9 or higher
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 295
diff changeset
2142 * @deprecated Use setCharacterStream
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2143 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2144 * @param x a java.io.InputStream object that contains the Unicode
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2145 * parameter value as two-byte Unicode characters
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2146 * @param length the number of bytes in the stream
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2147 * @throws SQLException if a database access error occurs
262
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
2148 * @throws SQLFeatureNotSupportedException the JDBC driver does
2d62ca1f758b Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
2149 * not support this method
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2150 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2151 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2152 @Deprecated
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2153 public void setUnicodeStream(final int parameterIndex, final InputStream x, final int length)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2154 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2155 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2156 throw newSQLFeatureNotSupportedException("setUnicodeStream");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2157 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2158
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2159 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2160 * Sets the designated parameter to the given java.net.URL value. The
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2161 * driver converts this to an SQL DATALINK value when it sends it to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2162 * database.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2163 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2164 * @param parameterIndex the first parameter is 1, the second is 2, ...
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2165 * @param x the java.net.URL object to be set
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2166 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2167 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2168 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2169 public void setURL(final int parameterIndex, final URL x) throws SQLException {
156
2abd488159c4 Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 155
diff changeset
2170 if (x == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2171 setValue(parameterIndex, "NULL");
156
2abd488159c4 Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 155
diff changeset
2172 return;
2abd488159c4 Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 155
diff changeset
2173 }
2abd488159c4 Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 155
diff changeset
2174
425
95d15f1d750d Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
2175 setValue(parameterIndex, "url " + MonetWrapper.sq(x.toString()));
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2176 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2177
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2178 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2179 * Releases this PreparedStatement object's database and JDBC
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2180 * resources immediately instead of waiting for this to happen when
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2181 * it is automatically closed. It is generally good practice to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2182 * release resources as soon as you are finished with them to avoid
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2183 * tying up database resources.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
2184 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2185 * Calling the method close on a PreparedStatement object that is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2186 * already closed has no effect.
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
2187 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2188 * <b>Note:</b> A PreparedStatement object is automatically closed
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2189 * when it is garbage collected. When a Statement object is closed,
12
a0e8adf10d41 Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
2190 * its current ResultSet object, if one exists, is also closed.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2191 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2192 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2193 public void close() {
623
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2194 if (!closed && id != -1) {
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2195 try {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2196 connection.sendControlCommand("release " + id);
623
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2197 } catch (SQLException e) {
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2198 // probably server closed connection
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2199 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2200 }
623
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2201 clearParameters();
717
7240d2dd369f Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 716
diff changeset
2202 rsmd = null;
719
2f42195e9c58 Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 717
diff changeset
2203 pmd = null;
623
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2204 mTimestampZ = null;
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2205 mTimestamp = null;
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2206 mTimeZ = null;
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2207 mTime = null;
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2208 mDate = null;
1c3cdf0667d7 Do more cleanup in the close() methods such as calling clearWarnings(), clearParameters(), clearBatch() and dereferencing cached objects.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 610
diff changeset
2209 execStmt = null;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2210 super.close();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2211 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2212
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2213 /**
451
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
2214 * Return the prepared SQL statement including parameter types and parameter values that were set.
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
2215 *
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
2216 * @return a String representing this Object
450
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2217 */
451
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
2218 @Override
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 450
diff changeset
2219 public String toString() {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2220 final StringBuilder sb = new StringBuilder(128 + paramCount * 64);
450
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2221 sb.append("Prepared SQL: ").append(sqlStatement).append("\n");
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2222 int param = 1;
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2223 for (int i = 0; i < size; i++) {
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2224 /* when column[i] == null it is a parameter, when column[i] != null it is a result column of the prepared query */
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2225 if (column[i] == null) {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2226 sb.append(" parameter ").append(param).append(" ").append(monetdbType[i]);
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2227 sb.append(", set value: ").append((paramValues[param] != null) ? paramValues[param] : "<null>").append("\n");
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2228 param++;
450
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2229 }
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2230 }
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2231 return sb.toString();
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2232 }
b9f82064fe0c Implemented PreparedStatement.toString() as requested by https://github.com/MonetDB/monetdb-java/issues/8
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 436
diff changeset
2233
376
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2234 //== Java 1.8 methods (JDBC 4.2)
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2235
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2236 @Override
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2237 public void setObject(final int parameterIndex, final Object x, final SQLType targetSqlType, final int scaleOrLength) throws SQLException {
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2238 // setObject(parameterIndex, x, convertSQLType(targetSqlType), scaleOrLength); // TODO implement convertSQLType(targetSqlType)
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2239 throw newSQLFeatureNotSupportedException("setObject");
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2240 }
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2241
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2242 @Override
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2243 public void setObject(final int parameterIndex, final Object x, final SQLType targetSqlType) throws SQLException {
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2244 // setObject(parameterIndex, x, convertSQLType(targetSqlType)); // TODO implement convertSQLType(targetSqlType)
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2245 throw newSQLFeatureNotSupportedException("setObject");
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2246 }
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2247
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2248 /**
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2249 * Executes the SQL statement in this PreparedStatement object, which must be
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2250 * an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE statement;
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2251 * or an SQL statement that returns nothing, such as a DDL statement.
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2252 *
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2253 * This method should be used when the returned row count may exceed Integer.MAX_VALUE.
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2254 * The default implementation will throw UnsupportedOperationException
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2255 *
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2256 * @return either (1) the row count for SQL Data Manipulation Language (DML) statements
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2257 * or (2) 0 for SQL statements that return nothing
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2258 * @throws SQLException if a database access error occurs; this method is called on a closed PreparedStatement
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2259 * or the SQL statement returns a ResultSet object
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2260 */
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2261 @Override
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2262 public long executeLargeUpdate() throws SQLException {
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2263 if (execute() != false)
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2264 throw new SQLException("Query produced a result set", "M1M17");
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2265
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
2266 return Math.max(getLargeUpdateCount(), 0L);
376
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2267 }
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2268
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2269 //== end methods interface PreparedStatement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2270
376
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2271
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2272 //== internal helper methods which do not belong to the JDBC interface
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 370
diff changeset
2273
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2274 /**
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2275 * Returns the index (0..size-1) in the backing arrays for the given
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2276 * parameter number or an SQLException when not valid
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2277 *
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2278 * @param paramnr the parameter number
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2279 * @return the internal column array index number
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2280 * @throws SQLException if parameter number is out of bounds
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2281 */
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2282 private final int getParamIdx(final int paramnr) throws SQLException {
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2283 if (paramnr < 1 || paramnr > paramCount || (paramnr + paramStartIndex > size))
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2284 throw new SQLException("No parameter with index: " + paramnr, "M1M05");
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2285
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2286 return paramnr + paramStartIndex -1;
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2287 }
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2288
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2289 /**
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2290 * Sets the given index with the supplied value. If the given index is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2291 * out of bounds, and SQLException is thrown. The given value should
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2292 * never be null.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2293 *
154
9a026aa272bb Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 144
diff changeset
2294 * @param parameterIndex the parameter index
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2295 * @param val the exact String representation to set
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2296 * @throws SQLException if the given index is out of bounds
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2297 */
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2298 private final void setValue(final int parameterIndex, final String val) throws SQLException {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2299 if (parameterIndex < 1 || parameterIndex > paramCount)
873
90e9d216b232 Optimised internal method getParamIdx(). Instead of going through a loop each time (for all result columns and parameters), we now calculate the internal array index value directly, which is much faster.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 867
diff changeset
2300 throw new SQLException("No parameter with index: " + parameterIndex, "M1M05");
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2301
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2302 if (val != null)
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2303 paramValues[parameterIndex] = val;
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2304 else
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2305 paramValues[parameterIndex] = "NULL";
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2306 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2307
708
5022a57f9d97 Resolve javadoc errors.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 696
diff changeset
2308 private StringBuilder execStmt; // created once, re-used multiple times so much less objects are created and gc-ed
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2309 /**
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2310 * Constructs an "exec ##(paramval, ...)" statement string for the current parameter values.
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2311 * Mind that the JDBC specs allow 'reuse' of a value for a parameter over multiple executes.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2312 *
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2313 * @return the "exec ##(...)" string
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2314 * @throws SQLException if not all parameters are set with a value
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2315 */
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
2316 private final String transform() throws SQLException {
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2317 if (execStmt == null)
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2318 // first time use, create it once
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2319 execStmt = new StringBuilder(32 + paramCount * 32);
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2320 else
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2321 execStmt.setLength(0); // clear the buffer
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2322
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2323 execStmt.append("exec ").append(id).append('(');
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2324 // check if all parameters are set and add the parameter values
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2325 for (int param = 1; param <= paramCount; param++) {
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2326 if (paramValues[param] == null)
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2327 throw new SQLException("Cannot execute, parameter " + param + " is missing.", "M1M05");
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2328 if (param > 1)
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2329 execStmt.append(',');
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2330 execStmt.append(paramValues[param]);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2331 }
473
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2332 execStmt.append(')');
6a6c86ac3232 Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
2333 return execStmt.toString();
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2334 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
2335 }