Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @ 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.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 03 Apr 2024 14:10:15 +0200 (13 months ago) |
parents | 90e9d216b232 |
children | 1956d8ba5ad3 |
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 * |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
815
diff
changeset
|
8 * Copyright 2024 MonetDB Foundation; |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
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 > ? and id < ?; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
58 * &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 |
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
|
147 * to retrieve all rows in one go, else we get eror: |
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 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
169 // initialise blank finals |
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();"); |
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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 final int column_colnr = rs.findColumn("column"); |
160
763150ec0a0a
Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
159
diff
changeset
|
188 for (int i = 0; rs.next(); i++) { |
763150ec0a0a
Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
159
diff
changeset
|
189 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
|
190 javaType[i] = MonetDriver.getJdbcSQLType(monetdbType[i]); |
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
|
191 if (javaType[i] == Types.CLOB) { |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
166
diff
changeset
|
192 if (connection.mapClobAsVarChar()) |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
166
diff
changeset
|
193 javaType[i] = Types.VARCHAR; |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
166
diff
changeset
|
194 } else |
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 if (javaType[i] == Types.BLOB) { |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
166
diff
changeset
|
196 if (connection.mapBlobAsVarBinary()) |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
166
diff
changeset
|
197 javaType[i] = Types.VARBINARY; |
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
330 return getUpdateCount(); |
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 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
360 int rescolcount = 0; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
361 for (int i = 0; i < size; i++) { |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
362 /* when column[i] == null it is a parameter, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
363 when column[i] != null it is a result column of the prepared query */ |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
364 if (column[i] == null) |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
365 continue; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
366 rescolcount++; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
367 } |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
368 int array_size = rescolcount; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
369 if (array_size == 0) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
370 // there are no resultset columns for this prepared statement |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
371 // we can not create arrays of size 0, so use: |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
372 array_size = 1; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
373 } |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
374 // create arrays for storing only the result columns meta data |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
375 final String[] schemas = new String[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
376 final String[] tables = new String[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
377 final String[] columns = new String[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
378 final String[] types = new String[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
379 final int[] jdbcTypes = new int[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
380 final int[] lengths = new int[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
381 final int[] precisions = new int[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
382 final int[] scales = new int[array_size]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
383 // now fill the arrays with only the resultset columns metadata |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
384 rescolcount = 0; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
385 for (int i = 0; i < size; i++) { |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
386 /* when column[i] == null it is a parameter, |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
387 when column[i] != null it is a result column of the prepared query */ |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
388 if (column[i] == null) |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
389 continue; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
390 schemas[rescolcount] = schema[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
391 tables[rescolcount] = table[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
392 columns[rescolcount] = column[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
393 types[rescolcount] = monetdbType[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
394 jdbcTypes[rescolcount] = javaType[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
395 switch (jdbcTypes[rescolcount]) { |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
396 case Types.BIGINT: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
397 lengths[rescolcount] = 19; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
398 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
|
399 case Types.INTEGER: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
400 lengths[rescolcount] = 10; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
401 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
|
402 case Types.SMALLINT: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
403 lengths[rescolcount] = 5; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
404 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
|
405 case Types.TINYINT: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
406 lengths[rescolcount] = 3; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
407 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
|
408 case Types.REAL: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
409 lengths[rescolcount] = 7; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
410 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
|
411 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
|
412 case Types.DOUBLE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
413 lengths[rescolcount] = 15; |
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 case Types.DATE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
416 lengths[rescolcount] = 10; // 2020-10-08 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
417 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
|
418 case Types.TIME: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
419 lengths[rescolcount] = 15; // 21:51:34.399753 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
420 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
|
421 case Types.TIME_WITH_TIMEZONE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
422 lengths[rescolcount] = 21; // 21:51:34.399753+02:00 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
423 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
|
424 case Types.TIMESTAMP: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
425 lengths[rescolcount] = 26; // 2020-10-08 21:51:34.399753 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
426 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
|
427 case Types.TIMESTAMP_WITH_TIMEZONE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
428 lengths[rescolcount] = 32; // 2020-10-08 21:51:34.399753+02:00 |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
429 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
|
430 case Types.BOOLEAN: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
431 lengths[rescolcount] = 5; // true or false |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
432 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
|
433 default: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
434 lengths[rescolcount] = digits[i]; |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
435 } |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
436 precisions[rescolcount] = digits[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
437 scales[rescolcount] = scale[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
438 rescolcount++; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
439 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
440 |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
441 rsmd = new MonetResultSetMetaData((MonetConnection) getConnection(), rescolcount, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
442 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
|
443 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
444 return rsmd; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
445 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
446 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
447 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
448 * Retrieves the number, types and properties of this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
449 * PreparedStatement object's parameters. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
450 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
451 * @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
|
452 * 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
|
453 * marker of this PreparedStatement object |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
454 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
455 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
456 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
457 public ParameterMetaData getParameterMetaData() throws SQLException { |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
458 if (pmd == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
459 // 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
|
460 // 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
|
461 final int array_size = paramCount +1; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
462 // 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 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
|
468 // 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
477 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
478 |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
479 pmd = new MonetParameterMetaData((MonetConnection) getConnection(), |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
480 paramCount, types, jdbcTypes, precisions, scales); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
481 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
482 return pmd; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
483 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
484 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
485 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
486 * 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
|
487 * 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
|
488 * the database. |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
489 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
490 * @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
|
491 * @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
|
492 * @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
|
493 * @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
|
494 * not support this method |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
495 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
496 @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
|
497 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
|
498 throw newSQLFeatureNotSupportedException("setArray"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
499 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
500 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
501 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
502 * 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
|
503 * 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
|
504 * 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
|
505 * 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
|
506 * 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
|
507 * 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
|
508 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
509 * 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
|
510 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
511 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
512 * @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
|
513 * @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
|
514 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
515 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
516 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
517 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
518 @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
|
519 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
|
520 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
521 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
522 throw newSQLFeatureNotSupportedException("setAsciiStream"); |
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
525 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
526 * 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
|
527 * 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
|
528 * 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
|
529 * 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
|
530 * 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
|
531 * 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
|
532 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
533 * 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
|
534 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
535 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
536 * @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
|
537 * @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
|
538 * @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
|
539 * @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
|
540 * @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
|
541 * not support this method |
0
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 @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
|
544 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
|
545 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
546 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
547 throw newSQLFeatureNotSupportedException("setAsciiStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
548 } |
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
551 * 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
|
552 * 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
|
553 * 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
|
554 * 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
|
555 * 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
|
556 * 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
|
557 * database char format. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
558 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
559 * 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
|
560 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
561 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
562 * @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
|
563 * @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
|
564 * @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
|
565 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
566 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
567 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
568 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
569 @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
|
570 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
|
571 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
572 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
573 throw newSQLFeatureNotSupportedException("setAsciiStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
574 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
575 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
576 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
577 * 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
|
578 * 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
|
579 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
580 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
581 * @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
|
582 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
583 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
584 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
585 @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
|
586 public void setBigDecimal(final int parameterIndex, BigDecimal x) throws SQLException { |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
587 // get array position |
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
|
588 final int i = getParamIdx(parameterIndex); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
589 |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
590 // round to the scale of the DB: |
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
|
591 x = x.setScale(scale[i], java.math.RoundingMode.HALF_UP); |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
592 |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
593 // if precision is now greater than that of the db, throw an error: |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
594 if (x.precision() > digits[i]) { |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
595 throw new SQLDataException("DECIMAL value exceeds allowed digits/scale: " + x.toPlainString() + " (" + digits[i] + "/" + scale[i] + ")", "22003"); |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
596 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
597 |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
598 // MonetDB doesn't like leading 0's, since it counts them as part of |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
599 // the precision, so let's strip them off. (But be careful not to do |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
600 // this to the exact number "0".) Also strip off trailing |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
601 // numbers that are inherent to the double representation. |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
602 String xStr = x.toPlainString(); |
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
|
603 final int dot = xStr.indexOf('.'); |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
604 if (dot >= 0) |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
605 xStr = xStr.substring(0, Math.min(xStr.length(), dot + 1 + scale[i])); |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
606 while (xStr.startsWith("0") && xStr.length() > 1) |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
607 xStr = xStr.substring(1); |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
608 setValue(parameterIndex, xStr); |
0
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
612 * 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
|
613 * 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
|
614 * 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
|
615 * 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
|
616 * 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
|
617 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
618 * 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
|
619 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
620 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
621 * @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
|
622 * @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
|
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) |
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 int 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 input stream, which will have |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
660 * 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
|
661 * 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
|
662 * 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
|
663 * 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
|
664 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
665 * 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
|
666 * your own subclass that implements the standard interface. |
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 * @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
|
669 * @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
|
670 * @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
|
671 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
672 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
673 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
674 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
675 @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
|
676 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
|
677 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
678 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
679 throw newSQLFeatureNotSupportedException("setBinaryStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
680 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
681 |
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 * 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
|
684 * 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
|
685 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
686 * @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
|
687 * @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
|
688 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
689 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
690 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
691 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
692 @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
|
693 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
|
694 throw newSQLFeatureNotSupportedException("setBlob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
695 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
696 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
697 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
698 * 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
|
699 * 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
|
700 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
701 * @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
|
702 * @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
|
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 Blob x) 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 a InputStream object. The |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
714 * 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
|
715 * 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
|
716 * PreparedStatement is executed. This method differs from the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
717 * setBinaryStream (int, InputStream, int) method because it informs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
718 * 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
|
719 * 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
|
720 * 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
|
721 * 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
|
722 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
723 * @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
|
724 * @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
|
725 * value to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
726 * @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
|
727 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
728 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
729 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
730 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
731 @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
|
732 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
|
733 throw newSQLFeatureNotSupportedException("setBlob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
734 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
735 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
736 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
737 * 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
|
738 * 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
|
739 * database. |
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 * @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
|
742 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
743 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
744 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
745 @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
|
746 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
|
747 setValue(parameterIndex, Boolean.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
748 } |
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
751 * 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
|
752 * 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
|
753 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
754 * @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
|
755 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
756 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
757 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
758 @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
|
759 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
|
760 setValue(parameterIndex, Byte.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
761 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
762 |
867
5a59910e8f87
Resolve some javadoc errors and warnings
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
833
diff
changeset
|
763 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
|
764 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
765 * 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
|
766 * 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
|
767 * 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
|
768 * values) when it sends it to the database. |
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 * @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
|
771 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
772 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
773 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
774 @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
|
775 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
|
776 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
|
777 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
778 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
779 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
780 |
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
|
781 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
|
782 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
|
783 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
|
784 // 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
|
785 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
|
786 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
|
787 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
|
788 .append(HEXES[(b & 0x0F)]); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
789 } |
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
|
790 hex.append("'"); // end of hex string value |
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
|
791 setValue(parameterIndex, hex.toString()); |
0
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
795 * 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
|
796 * 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
|
797 * 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
|
798 * 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
|
799 * 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
|
800 * 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
|
801 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
802 * 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
|
803 * 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
|
804 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
805 * @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
|
806 * @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
|
807 * @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
|
808 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
809 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
810 @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
|
811 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
|
812 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
813 { |
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
|
814 setClob(parameterIndex, reader, (long)length); |
0
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
817 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
818 * 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
|
819 * 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
|
820 * 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
|
821 * 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
|
822 * 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
|
823 * 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
|
824 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
825 * 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
|
826 * 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
|
827 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
828 * @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
|
829 * @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
|
830 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
831 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
832 @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
|
833 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
|
834 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
835 { |
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
|
836 setClob(parameterIndex, reader); |
0
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
840 * 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
|
841 * 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
|
842 * 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
|
843 * 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
|
844 * 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
|
845 * 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
|
846 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
847 * 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
|
848 * 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
|
849 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
850 * @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
|
851 * @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
|
852 * @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
|
853 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
854 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
855 @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
|
856 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
|
857 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
858 { |
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
|
859 setClob(parameterIndex, reader, length); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
860 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
861 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
862 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
863 * 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
|
864 * 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
|
865 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
866 * @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
|
867 * @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
|
868 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
869 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
870 @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
|
871 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
|
872 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
|
873 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
874 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
875 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
876 |
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
|
877 // 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
|
878 // efficient, but might work for a few cases... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
879 // 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
|
880 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
|
881 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
882 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
883 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
884 * 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
|
885 * 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
|
886 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
887 * @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
|
888 * @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
|
889 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
890 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
891 @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
|
892 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
|
893 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
|
894 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
895 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
896 } |
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
|
897 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
898 // 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
|
899 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
|
900 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
|
901 final StringBuilder buf = new StringBuilder(size * 32); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
902 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
|
903 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
|
904 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
|
905 buf.append(arr, 0, numChars); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
906 } |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
907 setString(parameterIndex, buf.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
908 } 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
|
909 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
|
910 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
911 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
912 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
913 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
914 * 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
|
915 * 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
|
916 * SQLException will be generated when the PreparedStatement is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
917 * executed. This method differs from the setCharacterStream (int, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
918 * 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
|
919 * 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
|
920 * 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
|
921 * 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
|
922 * 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
|
923 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
924 * @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
|
925 * @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
|
926 * @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
|
927 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
928 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
929 @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
|
930 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
|
931 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
|
932 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
933 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
934 } |
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
|
935 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
|
936 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
|
937 } |
65bf0be846f3
Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
326
diff
changeset
|
938 |
65bf0be846f3
Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
326
diff
changeset
|
939 // 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
|
940 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
|
941 try { |
815
17b8a0a84e62
Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
773
diff
changeset
|
942 long foo = 0; |
17b8a0a84e62
Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
773
diff
changeset
|
943 while (foo < length) { |
17b8a0a84e62
Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
773
diff
changeset
|
944 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
|
945 if (n < 0) |
17b8a0a84e62
Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
773
diff
changeset
|
946 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
|
947 foo += n; |
17b8a0a84e62
Call reader.read multiple times if necessary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
773
diff
changeset
|
948 } |
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
|
949 // 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
|
950 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
|
951 setString(parameterIndex, buf.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
952 } 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
|
953 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
|
954 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
955 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
956 |
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 * 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
|
959 * 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
|
960 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
961 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
962 * @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
|
963 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
964 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
965 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
966 @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
|
967 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
|
968 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
969 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
970 setDate(parameterIndex, x, null); |
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
973 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
974 * 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
|
975 * 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
|
976 * 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
|
977 * 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
|
978 * 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
|
979 * 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
|
980 * virtual machine running the application. |
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 * @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
|
983 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
984 * @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
|
985 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
986 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
987 @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
|
988 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
|
989 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
990 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
991 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
|
992 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
993 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
994 } |
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 if (cal == null) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
997 setValue(parameterIndex, "date '" + x.toString() + "'"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
998 } 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
|
999 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
|
1000 // 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
|
1001 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
|
1002 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1003 mDate.setTimeZone(cal.getTimeZone()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1004 setValue(parameterIndex, "date '" + mDate.format(x) + "'"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1005 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1006 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1007 |
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 * 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
|
1010 * 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
|
1011 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1012 * @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
|
1013 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1014 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1015 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1016 @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
|
1017 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
|
1018 setValue(parameterIndex, Double.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1019 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1020 |
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 * 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
|
1023 * 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
|
1024 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1025 * @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
|
1026 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1027 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1028 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1029 @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
|
1030 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
|
1031 setValue(parameterIndex, Float.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1032 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1033 |
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 * 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
|
1036 * 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
|
1037 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1038 * @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
|
1039 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1040 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1041 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1042 @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
|
1043 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
|
1044 setValue(parameterIndex, Integer.toString(x)); |
0
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1047 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1048 * 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
|
1049 * 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
|
1050 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1051 * @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
|
1052 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1053 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1054 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1055 @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
|
1056 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
|
1057 setValue(parameterIndex, Long.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1058 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1059 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1060 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1061 * 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
|
1062 * 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
|
1063 * 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
|
1064 * character set in the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1065 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1066 * @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
|
1067 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1068 * @throws SQLException if a database access error occurs |
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 @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
|
1071 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
|
1072 setCharacterStream(parameterIndex, value); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1073 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1074 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1075 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1076 * 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
|
1077 * 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
|
1078 * 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
|
1079 * character set in the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1080 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1081 * @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
|
1082 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1083 * @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
|
1084 * @throws SQLException if a database access error occurs |
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 @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
|
1087 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
|
1088 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1089 { |
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
|
1090 setCharacterStream(parameterIndex, value, length); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1091 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1092 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1093 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1094 * 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
|
1095 * 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
|
1096 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1097 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1098 * @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
|
1099 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1100 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1101 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1102 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1103 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1104 @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
|
1105 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
|
1106 throw newSQLFeatureNotSupportedException("setNClob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1107 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1108 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1109 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1110 * 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
|
1111 * 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
|
1112 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1113 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1114 * @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
|
1115 * @param value the parameter value |
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 NClob value) 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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1126 * 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
|
1127 * 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
|
1128 * SQLException will be generated when the PreparedStatement is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1129 * executed. This method differs from the setCharacterStream (int, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1130 * 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
|
1131 * 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
|
1132 * 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
|
1133 * 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
|
1134 * 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
|
1135 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1136 * @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
|
1137 * @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
|
1138 * value to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1139 * @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
|
1140 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1141 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1142 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1143 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1144 @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
|
1145 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
|
1146 throw newSQLFeatureNotSupportedException("setNClob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1147 } |
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1150 * Sets the designated paramter to the given String object. The |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1151 * 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
|
1152 * 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
|
1153 * 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
|
1154 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1155 * @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
|
1156 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1157 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1158 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1159 @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
|
1160 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
|
1161 setString(parameterIndex, value); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1162 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1163 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1164 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1165 * 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
|
1166 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1167 * 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
|
1168 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1169 * @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
|
1170 * @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
|
1171 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1172 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1173 @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
|
1174 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
|
1175 // 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
|
1176 // 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
|
1177 setValue(parameterIndex, "NULL"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1178 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1179 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1180 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1181 * 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
|
1182 * 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
|
1183 * 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
|
1184 * 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
|
1185 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1186 * 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
|
1187 * 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
|
1188 * 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
|
1189 * 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
|
1190 * 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
|
1191 * 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
|
1192 * 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
|
1193 * 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
|
1194 * 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
|
1195 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1196 * @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
|
1197 * @param sqlType a value from java.sql.Types |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1198 * @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
|
1199 * 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
|
1200 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1201 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1202 @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
|
1203 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
|
1204 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1205 { |
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
|
1206 // 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
|
1207 // 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
|
1208 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1209 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1210 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1211 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1212 * 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
|
1213 * 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
|
1214 * 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
|
1215 * types. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
1216 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1217 * 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
|
1218 * 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
|
1219 * 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
|
1220 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1221 * 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
|
1222 * 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
|
1223 * 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
|
1224 * 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
|
1225 * 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
|
1226 * 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
|
1227 * 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
|
1228 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1229 * 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
|
1230 * 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
|
1231 * of the interfaces named above. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1232 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1233 * @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
|
1234 * @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
|
1235 * @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
|
1236 * the given object is ambiguous |
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 @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
|
1239 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
|
1240 setObject(parameterIndex, x, javaType[getParamIdx(parameterIndex)], 0); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1241 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1242 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1243 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1244 * 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
|
1245 * 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
|
1246 * of zero. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1247 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1248 * @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
|
1249 * @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
|
1250 * @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
|
1251 * sent to the database |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1252 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1253 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1254 @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
|
1255 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
|
1256 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1257 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1258 setObject(parameterIndex, x, targetSqlType, 0); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1259 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1260 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1261 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1262 * 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
|
1263 * 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
|
1264 * 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
|
1265 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1266 * 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
|
1267 * 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
|
1268 * (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
|
1269 * 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
|
1270 * 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
|
1271 * 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
|
1272 * 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
|
1273 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1274 * 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
|
1275 * data types. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
1276 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1277 * 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
|
1278 * 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
|
1279 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1280 * @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
|
1281 * @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
|
1282 * @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
|
1283 * 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
|
1284 * further qualify this type. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1285 * @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
|
1286 * 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
|
1287 * point. For Java Object types InputStream and Reader, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1288 * 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
|
1289 * 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
|
1290 * ignored. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1291 * @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
|
1292 * @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
|
1293 * not support this method |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1294 * @see Types |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1295 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1296 @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
|
1297 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
|
1298 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1299 { |
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
|
1300 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
|
1301 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
|
1302 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
|
1303 } |
9ce094bd1bff
Improve method getObject() by checking on null Object to prevent NullPointerExceptions
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
156
diff
changeset
|
1304 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1305 // this is according to table B-5 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1306 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
|
1307 setString(parameterIndex, (String)x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1308 } else if (x instanceof BigDecimal || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1309 x instanceof Byte || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1310 x instanceof Short || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1311 x instanceof Integer || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1312 x instanceof Long || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1313 x instanceof Float || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1314 x instanceof Double) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1315 { |
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
|
1316 final Number num = (Number)x; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1317 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1318 case Types.TINYINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1319 setByte(parameterIndex, num.byteValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1320 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1321 case Types.SMALLINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1322 setShort(parameterIndex, num.shortValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1323 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1324 case Types.INTEGER: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1325 setInt(parameterIndex, num.intValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1326 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1327 case Types.BIGINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1328 if (x instanceof BigDecimal) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1329 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
|
1330 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
|
1331 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1332 setLong(parameterIndex, num.longValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1333 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1334 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1335 case Types.REAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1336 setFloat(parameterIndex, num.floatValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1337 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1338 case Types.FLOAT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1339 case Types.DOUBLE: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1340 setDouble(parameterIndex, num.doubleValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1341 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1342 case Types.DECIMAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1343 case Types.NUMERIC: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1344 if (x instanceof BigDecimal) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1345 setBigDecimal(parameterIndex, (BigDecimal)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1346 } 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
|
1347 setBigDecimal(parameterIndex, new BigDecimal(num.doubleValue())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1348 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1349 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1350 case Types.BOOLEAN: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1351 if (num.doubleValue() != 0.0) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1352 setBoolean(parameterIndex, true); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1353 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1354 setBoolean(parameterIndex, false); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1355 } |
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.CHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1358 case Types.VARCHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1359 case Types.LONGVARCHAR: |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1360 case Types.CLOB: |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1361 setString(parameterIndex, x.toString()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1362 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1363 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1364 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1365 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1366 } 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
|
1367 final boolean val = ((Boolean)x).booleanValue(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1368 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1369 case Types.TINYINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1370 setByte(parameterIndex, (byte)(val ? 1 : 0)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1371 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1372 case Types.SMALLINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1373 setShort(parameterIndex, (short)(val ? 1 : 0)); |
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.INTEGER: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1376 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
|
1377 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1378 case Types.BIGINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1379 setLong(parameterIndex, (long)(val ? 1 : 0)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1380 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1381 case Types.REAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1382 setFloat(parameterIndex, (float)(val ? 1.0 : 0.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 case Types.FLOAT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1385 case Types.DOUBLE: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1386 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
|
1387 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1388 case Types.DECIMAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1389 case Types.NUMERIC: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1390 { |
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
|
1391 final BigDecimal dec; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1392 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1393 dec = new BigDecimal(val ? 1.0 : 0.0); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1394 } catch (NumberFormatException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1395 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
|
1396 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1397 setBigDecimal(parameterIndex, dec); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1398 } break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1399 case Types.BOOLEAN: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1400 setBoolean(parameterIndex, val); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1401 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1402 case Types.CHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1403 case Types.VARCHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1404 case Types.LONGVARCHAR: |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1405 case Types.CLOB: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1406 setString(parameterIndex, x.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1407 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1408 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1409 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1410 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1411 } 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
|
1412 final BigInteger num = (BigInteger)x; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1413 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1414 case Types.BIGINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1415 setLong(parameterIndex, num.longValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1416 break; |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1417 case Types.DECIMAL: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1418 case Types.NUMERIC: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1419 { |
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
|
1420 final BigDecimal dec; |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1421 try { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1422 dec = new BigDecimal(num); |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1423 } catch (NumberFormatException e) { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1424 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
|
1425 } |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1426 setBigDecimal(parameterIndex, dec); |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1427 } break; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1428 case Types.CHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1429 case Types.VARCHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1430 case Types.LONGVARCHAR: |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1431 case Types.CLOB: |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1432 setString(parameterIndex, x.toString()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1433 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1434 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1435 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1436 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1437 } else if (x instanceof byte[]) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1438 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1439 case Types.BINARY: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1440 case Types.VARBINARY: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1441 case Types.LONGVARBINARY: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1442 setBytes(parameterIndex, (byte[])x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1443 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1444 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1445 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1446 } |
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
|
1447 } else if (x instanceof Date || |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1448 x instanceof Timestamp || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1449 x instanceof Time || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1450 x instanceof Calendar || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1451 x instanceof java.util.Date) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1452 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1453 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1454 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
|
1455 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
|
1456 setDate(parameterIndex, (Date)x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1457 } 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
|
1458 setDate(parameterIndex, new Date(((Timestamp)x).getTime())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1459 } 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
|
1460 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
|
1461 } 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
|
1462 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
|
1463 } else { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1464 throw new SQLException("Conversion not allowed", "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1465 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1466 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1467 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
|
1468 case Types.TIME_WITH_TIMEZONE: |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1469 if (x instanceof Time) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1470 setTime(parameterIndex, (Time)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1471 } else if (x instanceof Timestamp) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1472 setTime(parameterIndex, new Time(((Timestamp)x).getTime())); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1473 } 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
|
1474 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
|
1475 } 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
|
1476 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
|
1477 } else { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1478 throw new SQLException("Conversion not allowed", "M1M05"); |
0
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 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1481 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
|
1482 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
|
1483 if (x instanceof Timestamp) { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1484 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
|
1485 } 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
|
1486 setTimestamp(parameterIndex, new Timestamp(((Date)x).getTime())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1487 } 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
|
1488 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
|
1489 } 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
|
1490 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
|
1491 } else { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1492 throw new SQLException("Conversion not allowed", "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1493 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1494 break; |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1495 case Types.CHAR: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1496 case Types.VARCHAR: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1497 case Types.LONGVARCHAR: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1498 case Types.CLOB: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1499 setString(parameterIndex, x.toString()); |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1500 break; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1501 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1502 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1503 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1504 } else if (x instanceof Array) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1505 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
|
1506 } 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
|
1507 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
|
1508 } 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
|
1509 setClob(parameterIndex, (Clob)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1510 } else if (x instanceof Ref) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1511 setRef(parameterIndex, (Ref)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1512 } else if (x instanceof java.net.URL) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1513 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
|
1514 } 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
|
1515 setString(parameterIndex, x.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1516 } else if (x instanceof RowId) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1517 setRowId(parameterIndex, (RowId)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1518 } 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
|
1519 setNClob(parameterIndex, (NClob)x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1520 } 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
|
1521 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
|
1522 } 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
|
1523 final SQLData sx = (SQLData)x; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1524 final int paramnr = parameterIndex; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1525 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
|
1526 final SQLOutput out = new SQLOutput() { |
0
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 writeString(String x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1529 // special situation, this is when a string |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1530 // 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
|
1531 // 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
|
1532 // 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
|
1533 setValue(paramnr, sqltype + " " + MonetWrapper.sq(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1534 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1535 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1536 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1537 public void writeBoolean(boolean x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1538 setBoolean(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1539 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1542 public void writeByte(byte x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1543 setByte(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1544 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1547 public void writeShort(short x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1548 setShort(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1549 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1552 public void writeInt(int x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1553 setInt(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1554 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1557 public void writeLong(long x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1558 setLong(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1559 } |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1560 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1561 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1562 public void writeFloat(float x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1563 setFloat(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1564 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1567 public void writeDouble(double x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1568 setDouble(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1569 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1572 public void writeBigDecimal(BigDecimal x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1573 setBigDecimal(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1574 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1577 public void writeBytes(byte[] x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1578 setBytes(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1579 } |
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 @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
|
1582 public void writeDate(Date x) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1583 setDate(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1584 } |
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 @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
|
1587 public void writeTime(Time x) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1588 setTime(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1589 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1592 public void writeTimestamp(Timestamp x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1593 setTimestamp(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1594 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1597 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
|
1598 setCharacterStream(paramnr, x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1599 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1602 public void writeAsciiStream(InputStream x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1603 setAsciiStream(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1604 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1607 public void writeBinaryStream(InputStream x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1608 setBinaryStream(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1609 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1612 public void writeObject(SQLData x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1613 setObject(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1614 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1617 public void writeRef(Ref x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1618 setRef(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1619 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1622 public void writeBlob(Blob x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1623 setBlob(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1624 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1627 public void writeClob(Clob x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1628 setClob(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1629 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1632 public void writeStruct(Struct x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1633 setObject(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1634 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1637 public void writeArray(Array x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1638 setArray(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1639 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1642 public void writeURL(URL x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1643 setURL(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1644 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1645 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1646 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1647 public void writeNString(String x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1648 setNString(paramnr, x); |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1652 public void writeNClob(NClob x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1653 setNClob(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1654 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1655 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1656 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1657 public void writeRowId(RowId x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1658 setRowId(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1659 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1660 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1661 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1662 public void writeSQLXML(SQLXML x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1663 setSQLXML(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1664 } |
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 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
|
1667 } 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
|
1668 // 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
|
1669 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
|
1670 } 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
|
1671 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
|
1672 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1673 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1674 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1675 /** |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
1676 * Sets the designated parameter to the given REF(<structured-type>) value. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1677 * 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
|
1678 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1679 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1680 * @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
|
1681 * @param x an SQL REF value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1682 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1683 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1684 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1685 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1686 @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
|
1687 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
|
1688 throw newSQLFeatureNotSupportedException("setRef"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1689 } |
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1692 * 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
|
1693 * 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
|
1694 * the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1695 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1696 * @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
|
1697 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1698 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1699 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1700 * not support this method |
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 @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
|
1703 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
|
1704 throw newSQLFeatureNotSupportedException("setRowId"); |
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1707 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1708 * 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
|
1709 * 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
|
1710 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1711 * @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
|
1712 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1713 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1714 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1715 @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
|
1716 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
|
1717 setValue(parameterIndex, Short.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1718 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1719 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1720 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1721 * 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
|
1722 * 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
|
1723 * 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
|
1724 * it sends it to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1725 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1726 * @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
|
1727 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1728 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1729 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1730 @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
|
1731 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
|
1732 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
|
1733 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1734 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1735 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1736 |
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
|
1737 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
|
1738 |
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
|
1739 /* 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
|
1740 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
|
1741 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
|
1742 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
|
1743 |
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
|
1744 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
|
1745 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
|
1746 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
|
1747 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
|
1748 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
|
1749 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
|
1750 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
|
1751 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
|
1752 { |
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
|
1753 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
|
1754 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
|
1755 // 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
|
1756 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
|
1757 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
|
1758 // 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
|
1759 // 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
|
1760 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
|
1761 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
|
1762 } 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
|
1763 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
|
1764 } |
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
|
1765 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
|
1766 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
|
1767 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
|
1768 { |
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 // 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
|
1770 // 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
|
1771 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
|
1772 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
|
1773 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
|
1774 } 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
|
1775 // 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
|
1776 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
|
1777 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
|
1778 // 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
|
1779 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
|
1780 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
|
1781 && (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
|
1782 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
|
1783 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
|
1784 } |
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 // 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
|
1786 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
|
1787 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
|
1788 && (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
|
1789 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
|
1790 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
|
1791 } |
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
|
1792 |
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
|
1793 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
|
1794 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
|
1795 } 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
|
1796 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
|
1797 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
|
1798 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
|
1799 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
|
1800 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
|
1801 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
|
1802 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
|
1803 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
|
1804 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
|
1805 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
|
1806 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
|
1807 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
|
1808 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
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 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
|
1814 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
|
1815 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
|
1816 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
|
1817 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
|
1818 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
|
1819 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
|
1820 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
|
1821 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
|
1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 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
|
1832 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
|
1833 // 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
|
1834 // 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
|
1835 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
|
1836 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
|
1837 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
|
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 // 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
|
1843 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
|
1844 // 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
|
1845 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
|
1846 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
|
1847 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
|
1848 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
|
1849 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
|
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 // 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
|
1853 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
|
1854 // 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
|
1855 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
|
1856 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
|
1857 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
|
1858 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
|
1859 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
|
1860 } |
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
|
1861 // 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
|
1862 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
|
1863 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
|
1864 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
|
1865 } |
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
|
1866 } |
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
|
1867 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
|
1868 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
|
1869 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
|
1870 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
|
1871 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
|
1872 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
|
1873 } |
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
|
1874 } |
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
|
1875 } |
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
|
1876 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
|
1877 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
|
1878 |
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
|
1879 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
|
1880 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
|
1881 } |
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
|
1882 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
|
1883 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
|
1884 // 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
|
1885 // 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
|
1886 // 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
|
1887 // 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
|
1888 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
|
1889 } 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
|
1890 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
|
1891 } |
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
|
1892 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
|
1893 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
|
1894 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
|
1895 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
|
1896 // 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
|
1897 // 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
|
1898 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
|
1899 } 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
|
1900 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
|
1901 } |
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
|
1902 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
|
1903 break; |
642
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
624
diff
changeset
|
1904 // case "xml": |
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
624
diff
changeset
|
1905 // 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
|
1906 // 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
|
1907 // 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
|
1908 } |
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
|
1909 if (castprefix != null) { |
642
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
624
diff
changeset
|
1910 /* 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
|
1911 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
|
1912 } 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
|
1913 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
|
1914 } |
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
|
1915 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
|
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 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
|
1918 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
|
1919 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
|
1920 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
|
1921 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
|
1922 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
|
1923 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
|
1924 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
|
1925 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
|
1926 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
|
1927 // 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
|
1928 // 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
|
1929 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
|
1930 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
|
1931 } 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
|
1932 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
|
1933 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
|
1934 } 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
|
1935 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
|
1936 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
|
1937 } 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
|
1938 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
|
1939 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
|
1940 } |
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 } 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
|
1942 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
|
1943 } |
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 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
|
1945 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
|
1946 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
|
1947 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
|
1948 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
|
1949 } 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
|
1950 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
|
1951 } |
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 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
|
1953 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
|
1954 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
|
1955 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
|
1956 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
|
1957 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
|
1958 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
|
1959 // 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
|
1960 // 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
|
1961 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
|
1962 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
|
1963 } 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
|
1964 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
|
1965 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
|
1966 } 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
|
1967 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
|
1968 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
|
1969 } |
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 } 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
|
1971 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
|
1972 } |
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 /* 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
|
1974 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
|
1975 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
|
1976 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
|
1977 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
|
1978 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
|
1979 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
|
1980 // 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
|
1981 // 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
|
1982 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
|
1983 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
|
1984 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
|
1985 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
|
1986 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
|
1987 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
|
1988 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
|
1989 } |
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
|
1990 } |
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
|
1991 } |
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
|
1992 } |
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
|
1993 /* 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
|
1994 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
|
1995 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
|
1996 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
|
1997 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
|
1998 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1999 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2000 |
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 * 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
|
2003 * 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
|
2004 * sends it to the database. |
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 * @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
|
2007 * @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
|
2008 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2009 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2010 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2011 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2012 @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
|
2013 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
|
2014 throw newSQLFeatureNotSupportedException("setSQLXML"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2015 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2016 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2017 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2018 * 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
|
2019 * 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
|
2020 * the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2021 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2022 * @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
|
2023 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2024 * @throws SQLException if a database access error occurs |
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 @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
|
2027 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
|
2028 setTime(parameterIndex, x, null); |
0
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2031 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2032 * 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
|
2033 * 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
|
2034 * 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
|
2035 * 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
|
2036 * 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
|
2037 * 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
|
2038 * 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
|
2039 * application. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2040 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2041 * @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
|
2042 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2043 * @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
|
2044 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2045 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2046 @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
|
2047 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
|
2048 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2049 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2050 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
|
2051 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2052 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2053 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2054 |
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
|
2055 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
|
2056 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
|
2057 if (hasTimeZone) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2058 // 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
|
2059 // 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
|
2060 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
|
2061 // 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
|
2062 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
|
2063 } |
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
|
2064 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
|
2065 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
|
2066 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2067 // 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
|
2068 // 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
|
2069 // 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
|
2070 // here |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2071 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
|
2072 setValue(parameterIndex, "time '" + x.toString() + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2073 } 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
|
2074 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
|
2075 // 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
|
2076 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
|
2077 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2078 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
|
2079 setValue(parameterIndex, "time '" + mTime.format(x) + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2080 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2081 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2082 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2083 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2084 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2085 * 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
|
2086 * 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
|
2087 * it sends it to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2088 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2089 * @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
|
2090 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2091 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2092 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2093 @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
|
2094 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
|
2095 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2096 { |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2097 setTimestamp(parameterIndex, x, null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2098 } |
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2101 * 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
|
2102 * 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
|
2103 * 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
|
2104 * 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
|
2105 * 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
|
2106 * 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
|
2107 * 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
|
2108 * the application. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2109 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2110 * @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
|
2111 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2112 * @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
|
2113 * timestamp |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2114 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2115 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2116 @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
|
2117 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
|
2118 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2119 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2120 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
|
2121 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2122 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2123 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2124 |
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
|
2125 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
|
2126 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
|
2127 if (hasTimeZone) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2128 // 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
|
2129 // 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
|
2130 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
|
2131 // 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
|
2132 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
|
2133 } |
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
|
2134 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
|
2135 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
|
2136 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2137 // 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
|
2138 // 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
|
2139 // 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
|
2140 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
|
2141 setValue(parameterIndex, "timestamp '" + x.toString() + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2142 } 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
|
2143 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
|
2144 // 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
|
2145 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
|
2146 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2147 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
|
2148 setValue(parameterIndex, "timestamp '" + mTimestamp.format(x) + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2149 } |
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 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2152 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2153 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2154 * 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
|
2155 * 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
|
2156 * 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
|
2157 * 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
|
2158 * 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
|
2159 * 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
|
2160 * 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
|
2161 * 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
|
2162 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2163 * 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
|
2164 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2165 * |
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
|
2166 * @deprecated Use setCharacterStream |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2167 * @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
|
2168 * @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
|
2169 * parameter value as two-byte Unicode characters |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2170 * @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
|
2171 * @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
|
2172 * @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
|
2173 * not support this method |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2174 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2175 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2176 @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
|
2177 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
|
2178 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2179 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2180 throw newSQLFeatureNotSupportedException("setUnicodeStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2181 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2182 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2183 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2184 * 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
|
2185 * 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
|
2186 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2187 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2188 * @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
|
2189 * @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
|
2190 * @throws SQLException if a database access error occurs |
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 |
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
|
2193 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
|
2194 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
|
2195 setValue(parameterIndex, "NULL"); |
156
2abd488159c4
Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
155
diff
changeset
|
2196 return; |
2abd488159c4
Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
155
diff
changeset
|
2197 } |
2abd488159c4
Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
155
diff
changeset
|
2198 |
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
|
2199 setValue(parameterIndex, "url " + MonetWrapper.sq(x.toString())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2200 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2201 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2202 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2203 * Releases this PreparedStatement object's database and JDBC |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2204 * 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
|
2205 * 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
|
2206 * 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
|
2207 * 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
|
2208 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2209 * 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
|
2210 * 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
|
2211 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2212 * <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
|
2213 * 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
|
2214 * 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
|
2215 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2216 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2217 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
|
2218 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
|
2219 try { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2220 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
|
2221 } 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
|
2222 // 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
|
2223 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2224 } |
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
|
2225 clearParameters(); |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
2226 rsmd = null; |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 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
|
2232 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
|
2233 execStmt = null; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2234 super.close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2235 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2236 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2237 /** |
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
|
2238 * 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
|
2239 * |
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
|
2240 * @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
|
2241 */ |
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
|
2242 @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
|
2243 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
|
2244 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
|
2245 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
|
2246 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
|
2247 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
|
2248 /* 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
|
2249 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
|
2250 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
|
2251 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
|
2252 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
|
2253 } |
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
|
2254 } |
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
|
2255 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
|
2256 } |
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
|
2257 |
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
|
2258 //== 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
|
2259 |
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 @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
|
2261 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
|
2262 // 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
|
2263 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
|
2264 } |
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 |
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
|
2266 @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
|
2267 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
|
2268 // 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
|
2269 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
|
2270 } |
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 /** |
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 * 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
|
2274 * 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
|
2275 * 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
|
2276 * |
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
|
2277 * 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
|
2278 * 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
|
2279 * |
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
|
2280 * @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
|
2281 * 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
|
2282 * @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
|
2283 * 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
|
2284 */ |
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
|
2285 @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
|
2286 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
|
2287 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
|
2288 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
|
2289 |
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
|
2290 return getLargeUpdateCount(); |
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
|
2291 } |
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
|
2292 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2293 //== end methods interface PreparedStatement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2294 |
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
|
2295 |
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
|
2296 //== 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
|
2297 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2298 /** |
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
|
2299 * 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
|
2300 * 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
|
2301 * |
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
|
2302 * @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
|
2303 * @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
|
2304 * @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
|
2305 */ |
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
|
2306 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
|
2307 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
|
2308 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
|
2309 |
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
|
2310 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
|
2311 } |
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
|
2312 |
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
|
2313 /** |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2314 * 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
|
2315 * 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
|
2316 * never be null. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2317 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2318 * @param parameterIndex the parameter index |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2319 * @param val the exact String representation to set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2320 * @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
|
2321 */ |
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
|
2322 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
|
2323 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
|
2324 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
|
2325 |
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 (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
|
2327 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
|
2328 else |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2329 paramValues[parameterIndex] = "NULL"; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2330 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2331 |
708
5022a57f9d97
Resolve javadoc errors.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
696
diff
changeset
|
2332 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
|
2333 /** |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2334 * 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
|
2335 * 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
|
2336 * |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2337 * @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
|
2338 * @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
|
2339 */ |
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
|
2340 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
|
2341 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
|
2342 // 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
|
2343 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
|
2344 else |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2345 execStmt.setLength(0); // clear the buffer |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2346 |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2347 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
|
2348 // 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
|
2349 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
|
2350 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
|
2351 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
|
2352 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
|
2353 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
|
2354 execStmt.append(paramValues[param]); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2355 } |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2356 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
|
2357 return execStmt.toString(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2358 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2359 } |