Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @ 773:2bd1983f1c11
Reduce code by importing java.sql.Date; and remove prefix java.sql. where no longer needed.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 09 Aug 2023 21:19:21 +0200 (21 months ago) |
parents | b6d113ee35ae |
children | 17b8a0a84e62 |
rev | line source |
---|---|
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 /* |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2 * 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
|
3 * 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
|
4 * 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
|
5 * |
716
aeb268156580
Updated Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
714
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2023 MonetDB B.V. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
7 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
8 |
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
|
9 package org.monetdb.jdbc; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
10 |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
11 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
|
12 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
|
13 import java.io.Reader; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
14 import java.math.BigDecimal; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
15 import java.math.BigInteger; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
16 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
|
17 import java.nio.CharBuffer; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
18 import java.sql.Array; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
19 import java.sql.Blob; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
20 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
|
21 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
|
22 import java.sql.NClob; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
23 import java.sql.ParameterMetaData; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
24 import java.sql.PreparedStatement; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
25 import java.sql.Ref; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
26 import java.sql.ResultSet; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
27 import java.sql.ResultSetMetaData; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
28 import java.sql.RowId; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
29 import java.sql.SQLData; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
30 import java.sql.SQLDataException; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
31 import java.sql.SQLException; |
266
eefa7f625673
Resolve javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 import java.sql.SQLXML; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
36 import java.sql.Struct; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
37 import java.sql.Time; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
38 import java.sql.Timestamp; |
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
39 import java.sql.Types; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
40 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
|
41 import java.util.Calendar; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
42 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
43 /** |
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
|
44 *<pre> |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
45 * 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
|
46 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
47 * This implementation of the PreparedStatement interface uses the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
48 * 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
|
49 * 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
|
50 * 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
|
51 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
52 * 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
|
53 * % 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
|
54 * &5 0 2 3 2 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
55 * # prepare, prepare, prepare # table_name |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 * # type, digits, scale # name |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 * # varchar, int, int # type |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
58 * # 0, 0, 0 # length |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
59 * [ "int", 9, 0 ] |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
60 * [ "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
|
61 *</pre> |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
62 * |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
63 * @author Fabian Groffen |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
64 * @author Martin van Dinther |
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
|
65 * @version 0.7 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
66 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
67 public class MonetPreparedStatement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 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
|
69 implements PreparedStatement, AutoCloseable |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
70 { |
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
|
71 private final String sqlStatement; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
72 private final String[] monetdbType; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
73 private final int[] javaType; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
74 private final int[] digits; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
75 private final int[] scale; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
76 private final String[] schema; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
77 private final String[] table; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
78 private final String[] column; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
79 private final int id; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
80 private final int size; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
81 |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
82 private int paramCount = 0; |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
83 private final String[] paramValues; |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
84 |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
85 /** 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
|
86 * 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
|
87 private ResultSetMetaData rsmd; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
88 |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
89 /** 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
|
90 * 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
|
91 private ParameterMetaData pmd; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
92 |
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
|
93 /* 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
|
94 /** 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
|
95 private SimpleDateFormat mTimestampZ; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
96 /** 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
|
97 private SimpleDateFormat mTimestamp; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
98 /** 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
|
99 private SimpleDateFormat mTimeZ; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
100 /** 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
|
101 private SimpleDateFormat mTime; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
102 /** 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
|
103 private SimpleDateFormat mDate; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
104 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
105 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
106 * MonetPreparedStatement constructor which checks the arguments for |
624
71bcc7af90be
Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
623
diff
changeset
|
107 * 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
|
108 * 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
|
109 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
110 * @param connection the connection that created this Statement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
111 * @param resultSetType type of {@link ResultSet} to produce |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
112 * @param resultSetConcurrency concurrency of ResultSet to produce |
624
71bcc7af90be
Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
623
diff
changeset
|
113 * @param resultSetHoldability holdability of ResultSet to produce |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
114 * @param prepareQuery the query string to prepare |
624
71bcc7af90be
Cleanup old code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
623
diff
changeset
|
115 * @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
|
116 * @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
|
117 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 final String prepareQuery) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
124 throws SQLException, IllegalArgumentException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
125 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
126 super( |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
127 connection, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
128 resultSetType, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
129 resultSetConcurrency, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
130 resultSetHoldability |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
131 ); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
132 |
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
|
133 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
|
134 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
|
135 |
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
|
136 /** |
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
|
137 * For a PREPARE statement the server sends back a result set |
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
|
138 * with info on all the parameters and/or result columns of a |
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
|
139 * 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
|
140 * 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
|
141 * 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
|
142 * 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
|
143 * <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
|
144 * 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
|
145 */ |
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 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
|
147 // 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
|
148 // 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
|
149 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
|
150 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
151 if (!super.execute("PREPARE " + prepareQuery)) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
152 throw new SQLException("Unexpected server response", "M0M10"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
153 |
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
|
154 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
|
155 |
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
|
156 sqlStatement = prepareQuery; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
157 // 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
|
158 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
|
159 size = (int)((MonetConnection.ResultSetResponse)header).tuplecount; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
160 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
161 // initialise blank finals |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
162 monetdbType = new String[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
163 javaType = new int[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
164 digits = new int[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
165 scale = new int[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
166 schema = new String[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
167 table = new String[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
168 column = new String[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
169 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
170 // 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
|
171 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
|
172 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
|
173 // 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 } 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
|
187 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
|
188 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
|
189 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
|
190 } |
160
763150ec0a0a
Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
159
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 // 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
|
197 /* when column[i] != null it is a result column of the prepared query, |
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
|
198 when column[i] == null it is a parameter for the prepared statement, see getParamIdx(int). */ |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
199 if (column[i] == null) |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
200 paramCount++; |
160
763150ec0a0a
Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
159
diff
changeset
|
201 } |
763150ec0a0a
Improve constructor by preventing NPE when rs == null and
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
159
diff
changeset
|
202 rs.close(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
203 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
204 |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
205 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
|
206 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
207 // PreparedStatements are by default poolable |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
208 poolable = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
209 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
210 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
211 //== methods interface PreparedStatement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
212 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
213 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
214 * 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
|
215 * of commands. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
216 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
217 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
218 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
219 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
220 public void addBatch() throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
221 super.addBatch(transform()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
222 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
223 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
224 /** 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
|
225 @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
|
226 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
|
227 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
|
228 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
229 |
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 * 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
|
232 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
233 * 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
|
234 * 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
|
235 * 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
|
236 * 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
|
237 * calling the method clearParameters. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
238 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
239 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
240 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
|
241 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
|
242 paramValues[param] = null; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
243 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
244 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
245 |
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 * Executes the SQL statement in this PreparedStatement object, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
248 * 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
|
249 * 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
|
250 * 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
|
251 * 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
|
252 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
253 * 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
|
254 * 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
|
255 * getUpdateCount to retrieve the result; you must call |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
256 * getMoreResults to move to any subsequent result(s). |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
257 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
258 * @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
|
259 * 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
|
260 * @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
|
261 * is supplied to this method |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
264 public boolean execute() throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
265 return super.execute(transform()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
266 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
267 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
268 /** 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
|
269 @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
|
270 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
|
271 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
|
272 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
273 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
274 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
275 * 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
|
276 * ResultSet object generated by the query. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
277 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
278 * @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
|
279 * never null |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
280 * @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
|
281 * statement does not return a ResultSet object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
282 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
283 @Override |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
284 public ResultSet executeQuery() throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
285 if (execute() != true) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
286 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
|
287 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
288 return getResultSet(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
289 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
290 |
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
|
291 /** 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
|
292 @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
|
293 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
|
294 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
|
295 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
296 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
297 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
298 * 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
|
299 * 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
|
300 * returns nothing, such as a DDL statement. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
301 * |
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
|
302 * @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
|
303 * 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
|
304 * @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
|
305 * statement returns a ResultSet object |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
306 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
307 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
308 public int executeUpdate() throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
309 if (execute() != false) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
310 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
|
311 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
312 return getUpdateCount(); |
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 |
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
|
315 /** 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
|
316 @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
|
317 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
|
318 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
|
319 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
320 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
321 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
322 * Returns the index (0..size-1) in the backing arrays for the given |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
323 * parameter number or an SQLException when not found |
709
bdeabbd46ec6
Resolve javac and javadoc warnings when compiled with JDK19.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
708
diff
changeset
|
324 * |
bdeabbd46ec6
Resolve javac and javadoc warnings when compiled with JDK19.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
708
diff
changeset
|
325 * @param paramnr the parameter number |
bdeabbd46ec6
Resolve javac and javadoc warnings when compiled with JDK19.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
708
diff
changeset
|
326 * @return the internal column array index number |
bdeabbd46ec6
Resolve javac and javadoc warnings when compiled with JDK19.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
708
diff
changeset
|
327 * @throws SQLException if parameter number can not be found in the internal array |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
328 */ |
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
|
329 private final int getParamIdx(final int paramnr) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
330 int curparam = 0; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
331 for (int i = 0; i < size; i++) { |
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
|
332 /* when column[i] == null it is a parameter, when column[i] != null it is a result column of the prepared query */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
333 if (column[i] != null) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
334 continue; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
335 curparam++; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
336 if (curparam == paramnr) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
337 return i; |
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 throw new SQLException("No such parameter with index: " + paramnr, "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
340 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
341 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
342 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
343 * Retrieves a ResultSetMetaData object that contains information |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
344 * 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
|
345 * 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
|
346 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
347 * 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
|
348 * 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
|
349 * 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
|
350 * method getMetaData on a PreparedStatement object rather than |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
351 * 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
|
352 * method on the ResultSet object that is returned. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
353 * |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
354 * @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
|
355 * the driver cannot return a ResultSetMetaData object |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
356 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
357 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
358 @Override |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
359 public ResultSetMetaData getMetaData() throws SQLException { |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
360 if (rsmd == null) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
361 // 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
|
362 // 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
|
363 int rescolcount = 0; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
364 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
|
365 /* 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
|
366 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
|
367 if (column[i] == null) |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
368 continue; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
369 rescolcount++; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
370 } |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
371 int array_size = rescolcount; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
372 if (array_size == 0) { |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
373 // 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
|
374 // 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
|
375 array_size = 1; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
376 } |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
377 // 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 // 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
|
387 rescolcount = 0; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
388 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
|
389 /* 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
|
390 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
|
391 if (column[i] == null) |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
392 continue; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
393 schemas[rescolcount] = schema[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
394 tables[rescolcount] = table[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
395 columns[rescolcount] = column[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
396 types[rescolcount] = monetdbType[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
397 jdbcTypes[rescolcount] = javaType[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
398 switch (jdbcTypes[rescolcount]) { |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
399 case Types.BIGINT: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
400 lengths[rescolcount] = 19; |
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.INTEGER: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
403 lengths[rescolcount] = 10; |
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.SMALLINT: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
406 lengths[rescolcount] = 5; |
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.TINYINT: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
409 lengths[rescolcount] = 3; |
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.REAL: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
412 lengths[rescolcount] = 7; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
413 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
|
414 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
|
415 case Types.DOUBLE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
416 lengths[rescolcount] = 15; |
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.DATE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
419 lengths[rescolcount] = 10; // 2020-10-08 |
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: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
422 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
|
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.TIME_WITH_TIMEZONE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
425 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
|
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: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
428 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
|
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.TIMESTAMP_WITH_TIMEZONE: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
431 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
|
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 case Types.BOOLEAN: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
434 lengths[rescolcount] = 5; // true or false |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
435 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
|
436 default: |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
437 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
|
438 } |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
439 precisions[rescolcount] = digits[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
440 scales[rescolcount] = scale[i]; |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
441 rescolcount++; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
442 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
443 |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
444 rsmd = new MonetResultSetMetaData((MonetConnection) getConnection(), rescolcount, |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
445 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
|
446 } |
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
447 return rsmd; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
448 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
449 |
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 * Retrieves the number, types and properties of this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
452 * PreparedStatement object's parameters. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
453 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
454 * @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
|
455 * 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
|
456 * marker of this PreparedStatement object |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
457 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
458 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
459 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
460 public ParameterMetaData getParameterMetaData() throws SQLException { |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
461 if (pmd == null) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
462 // 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
|
463 // 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
|
464 final int array_size = paramCount +1; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
465 // 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
|
466 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
|
467 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
|
468 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
|
469 final int[] scales = new int[array_size]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
470 int param = 1; // parameters in JDBC start from 1 |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
471 // now fill the arrays with only the parameters metadata |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
472 for (int i = 0; i < size; i++) { |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
473 /* 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
|
474 when column[i] != null it is a result column of the prepared query */ |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
475 if (column[i] != null) |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
476 continue; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
477 types[param] = monetdbType[i]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
478 jdbcTypes[param] = javaType[i]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
479 precisions[param] = digits[i]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
480 scales[param] = scale[i]; |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
481 param++; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
482 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
483 |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
484 pmd = new MonetParameterMetaData((MonetConnection) getConnection(), |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
485 paramCount, types, jdbcTypes, precisions, scales); |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
486 } |
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
487 return pmd; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
488 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
489 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
490 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
491 * 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
|
492 * 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
|
493 * the database. |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
494 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
495 * @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
|
496 * @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
|
497 * @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
|
498 * @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
|
499 * not support this method |
0
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 @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
|
502 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
|
503 throw newSQLFeatureNotSupportedException("setArray"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
504 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
505 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
506 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
507 * Sets the designated parameter to the given input stream, which will have |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
508 * the specified number of bytes. When a very large ASCII value is input to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
509 * a LONGVARCHAR parameter, it may be more practical to send it via a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
510 * java.io.InputStream. Data will be read from the stream as needed until |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
511 * end-of-file is reached. The JDBC driver will do any necessary conversion |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
512 * from ASCII to the database char format. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
513 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
514 * Note: This stream object can either be a standard Java stream object or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
515 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
516 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
517 * @param parameterIndex the first parameter is 1, the second is 2, ... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
518 * @param x the Java input stream that contains the ASCII parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
519 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
520 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
521 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
522 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
523 @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
|
524 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
|
525 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
526 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
527 throw newSQLFeatureNotSupportedException("setAsciiStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
528 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
529 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
530 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
531 * 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
|
532 * 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
|
533 * 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
|
534 * 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
|
535 * 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
|
536 * 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
|
537 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
538 * 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
|
539 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
540 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
541 * @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
|
542 * @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
|
543 * @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
|
544 * @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
|
545 * @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
|
546 * not support this method |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
547 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
548 @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
|
549 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
|
550 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
551 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
552 throw newSQLFeatureNotSupportedException("setAsciiStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
553 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
554 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
555 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
556 * 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
|
557 * 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
|
558 * 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
|
559 * 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
|
560 * 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
|
561 * 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
|
562 * database char format. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
563 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
564 * 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
|
565 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
566 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
567 * @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
|
568 * @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
|
569 * @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
|
570 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
571 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
572 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
573 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
574 @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
|
575 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
|
576 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
577 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
578 throw newSQLFeatureNotSupportedException("setAsciiStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
579 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
580 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
581 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
582 * 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
|
583 * 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
|
584 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
585 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
586 * @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
|
587 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
588 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
589 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
590 @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
|
591 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
|
592 // 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
|
593 final int i = getParamIdx(parameterIndex); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
594 |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
595 // 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
|
596 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
|
597 |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
598 // 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
|
599 if (x.precision() > digits[i]) { |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
600 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
|
601 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
602 |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
603 // 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
|
604 // 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
|
605 // 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
|
606 // 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
|
607 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
|
608 final int dot = xStr.indexOf('.'); |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
609 if (dot >= 0) |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
610 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
|
611 while (xStr.startsWith("0") && xStr.length() > 1) |
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
612 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
|
613 setValue(parameterIndex, xStr); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
614 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
615 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
616 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
617 * 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
|
618 * 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
|
619 * 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
|
620 * 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
|
621 * 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
|
622 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
623 * 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
|
624 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
625 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
626 * @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
|
627 * @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
|
628 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
629 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
630 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
631 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
632 @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
|
633 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
|
634 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
635 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
636 throw newSQLFeatureNotSupportedException("setBinaryStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
637 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
638 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
639 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
640 * 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
|
641 * 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
|
642 * 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
|
643 * 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
|
644 * 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
|
645 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
646 * 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
|
647 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
648 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
649 * @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
|
650 * @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
|
651 * @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
|
652 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
653 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
654 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
655 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
656 @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
|
657 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
|
658 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
659 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
660 throw newSQLFeatureNotSupportedException("setBinaryStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
661 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
662 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
663 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
664 * 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
|
665 * 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
|
666 * 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
|
667 * 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
|
668 * 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
|
669 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
670 * 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
|
671 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
672 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
673 * @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
|
674 * @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
|
675 * @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
|
676 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
677 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
678 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
679 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
680 @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
|
681 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
|
682 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
683 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
684 throw newSQLFeatureNotSupportedException("setBinaryStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
685 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
686 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
687 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
688 * 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
|
689 * 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
|
690 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
691 * @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
|
692 * @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
|
693 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
694 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
695 * not support this method |
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 @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
|
698 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
|
699 throw newSQLFeatureNotSupportedException("setBlob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
700 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
701 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
702 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
703 * 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
|
704 * 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
|
705 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
706 * @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
|
707 * @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
|
708 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
709 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
710 * not support this method |
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 @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
|
713 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
|
714 throw newSQLFeatureNotSupportedException("setBlob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
715 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
716 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
717 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
718 * 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
|
719 * 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
|
720 * 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
|
721 * PreparedStatement is executed. This method differs from the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
722 * setBinaryStream (int, InputStream, int) method because it informs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
723 * 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
|
724 * 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
|
725 * 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
|
726 * 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
|
727 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
728 * @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
|
729 * @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
|
730 * value to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
731 * @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
|
732 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
733 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
734 * not support this method |
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 @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
|
737 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
|
738 throw newSQLFeatureNotSupportedException("setBlob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
739 } |
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 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
742 * 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
|
743 * 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
|
744 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
745 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
746 * @param parameterIndex the first parameter is 1, the second is 2, ... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
747 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
748 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
749 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
750 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
751 public void 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
|
752 setValue(parameterIndex, Boolean.toString(x)); |
0
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 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
755 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
756 * 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
|
757 * 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
|
758 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
759 * @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
|
760 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
761 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
762 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
763 @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
|
764 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
|
765 setValue(parameterIndex, Byte.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
766 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
767 |
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
|
768 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
|
769 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
770 * 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
|
771 * 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
|
772 * 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
|
773 * values) when it sends it to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
774 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
775 * @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
|
776 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
777 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
778 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
779 @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
|
780 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
|
781 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
|
782 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
783 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
784 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
785 |
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
|
786 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
|
787 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
|
788 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
|
789 // 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
|
790 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
|
791 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
|
792 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
|
793 .append(HEXES[(b & 0x0F)]); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
794 } |
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
|
795 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
|
796 setValue(parameterIndex, hex.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
797 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
798 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
799 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
800 * 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
|
801 * 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
|
802 * 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
|
803 * 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
|
804 * 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
|
805 * 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
|
806 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
807 * 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
|
808 * 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
|
809 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
810 * @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
|
811 * @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
|
812 * @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
|
813 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
814 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
815 @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
|
816 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
|
817 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
818 { |
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
|
819 setClob(parameterIndex, reader, (long)length); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
820 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
821 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
822 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
823 * 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
|
824 * 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
|
825 * 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
|
826 * 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
|
827 * 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
|
828 * 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
|
829 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
830 * 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
|
831 * 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
|
832 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
833 * @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
|
834 * @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
|
835 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
836 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
837 @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
|
838 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
|
839 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
840 { |
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
|
841 setClob(parameterIndex, reader); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
842 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
843 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
844 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
845 * 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
|
846 * 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
|
847 * 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
|
848 * 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
|
849 * 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
|
850 * 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
|
851 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
852 * 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
|
853 * 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
|
854 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
855 * @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
|
856 * @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
|
857 * @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
|
858 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
859 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
860 @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
|
861 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
|
862 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
863 { |
328
65bf0be846f3
Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
326
diff
changeset
|
864 setClob(parameterIndex, reader, length); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
865 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
866 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
867 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
868 * 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
|
869 * 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
|
870 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
871 * @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
|
872 * @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
|
873 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
874 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
875 @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
|
876 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
|
877 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
|
878 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
879 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
880 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
881 |
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
|
882 // 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
|
883 // efficient, but might work for a few cases... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
884 // 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
|
885 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
|
886 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
887 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
888 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
889 * 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
|
890 * 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
|
891 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
892 * @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
|
893 * @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
|
894 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
895 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
896 @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
|
897 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
|
898 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
|
899 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
900 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
901 } |
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
|
902 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
903 // 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
|
904 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
|
905 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
|
906 final StringBuilder buf = new StringBuilder(size * 32); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
907 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
|
908 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
|
909 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
|
910 buf.append(arr, 0, numChars); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
911 } |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
912 setString(parameterIndex, buf.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
913 } 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
|
914 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
|
915 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
916 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
917 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
918 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
919 * 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
|
920 * 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
|
921 * SQLException will be generated when the PreparedStatement is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
922 * executed. This method differs from the setCharacterStream (int, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
923 * 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
|
924 * 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
|
925 * 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
|
926 * 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
|
927 * 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
|
928 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
929 * @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
|
930 * @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
|
931 * @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
|
932 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
933 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
934 @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
|
935 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
|
936 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
|
937 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
938 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
939 } |
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
|
940 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
|
941 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
|
942 } |
65bf0be846f3
Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
326
diff
changeset
|
943 |
65bf0be846f3
Removed duplicate code from setCharacterStream(int parameterIndex, Reader reader, long length).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
326
diff
changeset
|
944 // 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
|
945 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
|
946 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
947 reader.read(buf); |
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
|
948 // 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
|
949 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
|
950 setString(parameterIndex, buf.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
951 } 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
|
952 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
|
953 } |
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 * 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
|
958 * 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
|
959 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
960 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
961 * @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
|
962 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
963 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
964 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
965 @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
|
966 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
|
967 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
968 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
969 setDate(parameterIndex, x, null); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
970 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
971 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
972 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
973 * 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
|
974 * 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
|
975 * 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
|
976 * 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
|
977 * 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
|
978 * 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
|
979 * virtual machine running the application. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
980 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
981 * @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
|
982 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
983 * @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
|
984 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
985 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
986 @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
|
987 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
|
988 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
989 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
990 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
|
991 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
992 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
993 } |
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 if (cal == null) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
996 setValue(parameterIndex, "date '" + x.toString() + "'"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
997 } 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
|
998 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
|
999 // 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
|
1000 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
|
1001 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1002 mDate.setTimeZone(cal.getTimeZone()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1003 setValue(parameterIndex, "date '" + mDate.format(x) + "'"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1004 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1005 } |
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 * 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
|
1009 * 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
|
1010 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1011 * @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
|
1012 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1013 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1014 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1015 @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
|
1016 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
|
1017 setValue(parameterIndex, Double.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1018 } |
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 * 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
|
1022 * 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
|
1023 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1024 * @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
|
1025 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1026 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1027 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1028 @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
|
1029 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
|
1030 setValue(parameterIndex, Float.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1031 } |
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 * 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
|
1035 * 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
|
1036 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1037 * @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
|
1038 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1039 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1040 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1041 @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
|
1042 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
|
1043 setValue(parameterIndex, Integer.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1044 } |
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 * 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
|
1048 * 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
|
1049 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1050 * @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
|
1051 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1052 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1053 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1054 @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
|
1055 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
|
1056 setValue(parameterIndex, Long.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1057 } |
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 * 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
|
1061 * 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
|
1062 * 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
|
1063 * character set in the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1064 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1065 * @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
|
1066 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1067 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1068 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1069 @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
|
1070 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
|
1071 setCharacterStream(parameterIndex, value); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1072 } |
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 * 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
|
1076 * 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
|
1077 * 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
|
1078 * character set in the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1079 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1080 * @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
|
1081 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1082 * @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
|
1083 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1084 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1085 @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
|
1086 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
|
1087 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1088 { |
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
|
1089 setCharacterStream(parameterIndex, value, length); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1090 } |
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 * 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
|
1094 * 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
|
1095 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1096 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1097 * @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
|
1098 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1099 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1100 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1101 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1102 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1103 @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
|
1104 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
|
1105 throw newSQLFeatureNotSupportedException("setNClob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1106 } |
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 * 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
|
1110 * 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
|
1111 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1112 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1113 * @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
|
1114 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1115 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1116 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1117 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1118 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1119 @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
|
1120 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
|
1121 throw newSQLFeatureNotSupportedException("setNClob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1122 } |
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 * 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
|
1126 * 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
|
1127 * SQLException will be generated when the PreparedStatement is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1128 * executed. This method differs from the setCharacterStream (int, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1129 * 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
|
1130 * 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
|
1131 * 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
|
1132 * 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
|
1133 * 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
|
1134 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1135 * @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
|
1136 * @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
|
1137 * value to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1138 * @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
|
1139 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1140 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1141 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1142 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1143 @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
|
1144 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
|
1145 throw newSQLFeatureNotSupportedException("setNClob"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1146 } |
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 * 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
|
1150 * 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
|
1151 * 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
|
1152 * 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
|
1153 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1154 * @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
|
1155 * @param value the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1156 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1157 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1158 @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
|
1159 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
|
1160 setString(parameterIndex, value); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1161 } |
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 * 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
|
1165 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1166 * 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
|
1167 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1168 * @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
|
1169 * @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
|
1170 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1171 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1172 @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
|
1173 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
|
1174 // 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
|
1175 // 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
|
1176 setValue(parameterIndex, "NULL"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1177 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1178 |
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 * 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
|
1181 * 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
|
1182 * 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
|
1183 * 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
|
1184 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1185 * 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
|
1186 * 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
|
1187 * 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
|
1188 * 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
|
1189 * 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
|
1190 * 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
|
1191 * 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
|
1192 * 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
|
1193 * 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
|
1194 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1195 * @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
|
1196 * @param sqlType a value from java.sql.Types |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1197 * @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
|
1198 * 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
|
1199 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1200 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1201 @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
|
1202 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
|
1203 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1204 { |
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
|
1205 // 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
|
1206 // 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
|
1207 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1208 } |
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 * 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
|
1212 * 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
|
1213 * 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
|
1214 * types. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
1215 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1216 * 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
|
1217 * 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
|
1218 * 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
|
1219 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1220 * 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
|
1221 * 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
|
1222 * 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
|
1223 * 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
|
1224 * 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
|
1225 * 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
|
1226 * 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
|
1227 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1228 * 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
|
1229 * 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
|
1230 * of the interfaces named above. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1231 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1232 * @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
|
1233 * @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
|
1234 * @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
|
1235 * the given object is ambiguous |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1236 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1237 @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
|
1238 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
|
1239 setObject(parameterIndex, x, javaType[getParamIdx(parameterIndex)], 0); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1240 } |
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 * 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
|
1244 * 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
|
1245 * of zero. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1246 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1247 * @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
|
1248 * @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
|
1249 * @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
|
1250 * sent to the database |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1251 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1252 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1253 @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
|
1254 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
|
1255 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1256 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1257 setObject(parameterIndex, x, targetSqlType, 0); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1258 } |
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 * 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
|
1262 * 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
|
1263 * 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
|
1264 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1265 * 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
|
1266 * 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
|
1267 * (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
|
1268 * 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
|
1269 * 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
|
1270 * 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
|
1271 * 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
|
1272 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1273 * 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
|
1274 * data types. |
12
a0e8adf10d41
Improved ResultSetMetaData methods isAutoIncrement(), getPrecision(), getScale(), isNullable().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
1275 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1276 * 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
|
1277 * 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
|
1278 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1279 * @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
|
1280 * @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
|
1281 * @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
|
1282 * 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
|
1283 * further qualify this type. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1284 * @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
|
1285 * 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
|
1286 * point. For Java Object types InputStream and Reader, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1287 * 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
|
1288 * 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
|
1289 * ignored. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1290 * @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
|
1291 * @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
|
1292 * not support this method |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1293 * @see Types |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1294 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1295 @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
|
1296 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
|
1297 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1298 { |
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
|
1299 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
|
1300 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
|
1301 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
|
1302 } |
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 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1304 // this is according to table B-5 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1305 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
|
1306 setString(parameterIndex, (String)x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1307 } else if (x instanceof BigDecimal || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1308 x instanceof Byte || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1309 x instanceof Short || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1310 x instanceof Integer || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1311 x instanceof Long || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1312 x instanceof Float || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1313 x instanceof Double) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1314 { |
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
|
1315 final Number num = (Number)x; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1316 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1317 case Types.TINYINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1318 setByte(parameterIndex, num.byteValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1319 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1320 case Types.SMALLINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1321 setShort(parameterIndex, num.shortValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1322 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1323 case Types.INTEGER: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1324 setInt(parameterIndex, num.intValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1325 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1326 case Types.BIGINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1327 if (x instanceof BigDecimal) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1328 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
|
1329 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
|
1330 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1331 setLong(parameterIndex, num.longValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1332 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1333 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1334 case Types.REAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1335 setFloat(parameterIndex, num.floatValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1336 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1337 case Types.FLOAT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1338 case Types.DOUBLE: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1339 setDouble(parameterIndex, num.doubleValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1340 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1341 case Types.DECIMAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1342 case Types.NUMERIC: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1343 if (x instanceof BigDecimal) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1344 setBigDecimal(parameterIndex, (BigDecimal)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1345 } 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
|
1346 setBigDecimal(parameterIndex, new BigDecimal(num.doubleValue())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1347 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1348 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1349 case Types.BOOLEAN: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1350 if (num.doubleValue() != 0.0) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1351 setBoolean(parameterIndex, true); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1352 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1353 setBoolean(parameterIndex, false); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1354 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1355 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1356 case Types.CHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1357 case Types.VARCHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1358 case Types.LONGVARCHAR: |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1359 case Types.CLOB: |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1360 setString(parameterIndex, x.toString()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1361 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1362 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1363 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1364 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1365 } 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
|
1366 final boolean val = ((Boolean)x).booleanValue(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1367 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1368 case Types.TINYINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1369 setByte(parameterIndex, (byte)(val ? 1 : 0)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1370 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1371 case Types.SMALLINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1372 setShort(parameterIndex, (short)(val ? 1 : 0)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1373 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1374 case Types.INTEGER: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1375 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
|
1376 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1377 case Types.BIGINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1378 setLong(parameterIndex, (long)(val ? 1 : 0)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1379 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1380 case Types.REAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1381 setFloat(parameterIndex, (float)(val ? 1.0 : 0.0)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1382 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1383 case Types.FLOAT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1384 case Types.DOUBLE: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1385 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
|
1386 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1387 case Types.DECIMAL: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1388 case Types.NUMERIC: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1389 { |
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
|
1390 final BigDecimal dec; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1391 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1392 dec = new BigDecimal(val ? 1.0 : 0.0); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1393 } catch (NumberFormatException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1394 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
|
1395 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1396 setBigDecimal(parameterIndex, dec); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1397 } break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1398 case Types.BOOLEAN: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1399 setBoolean(parameterIndex, val); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1400 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1401 case Types.CHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1402 case Types.VARCHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1403 case Types.LONGVARCHAR: |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1404 case Types.CLOB: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1405 setString(parameterIndex, x.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1406 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1407 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1408 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1409 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1410 } 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
|
1411 final BigInteger num = (BigInteger)x; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1412 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1413 case Types.BIGINT: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1414 setLong(parameterIndex, num.longValue()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1415 break; |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1416 case Types.DECIMAL: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1417 case Types.NUMERIC: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1418 { |
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
|
1419 final BigDecimal dec; |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1420 try { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1421 dec = new BigDecimal(num); |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1422 } catch (NumberFormatException e) { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1423 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
|
1424 } |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1425 setBigDecimal(parameterIndex, dec); |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1426 } break; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1427 case Types.CHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1428 case Types.VARCHAR: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1429 case Types.LONGVARCHAR: |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1430 case Types.CLOB: |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1431 setString(parameterIndex, x.toString()); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1432 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1433 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1434 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1435 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1436 } else if (x instanceof byte[]) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1437 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1438 case Types.BINARY: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1439 case Types.VARBINARY: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1440 case Types.LONGVARBINARY: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1441 setBytes(parameterIndex, (byte[])x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1442 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1443 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1444 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1445 } |
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
|
1446 } else if (x instanceof Date || |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1447 x instanceof Timestamp || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1448 x instanceof Time || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1449 x instanceof Calendar || |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1450 x instanceof java.util.Date) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1451 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1452 switch (targetSqlType) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1453 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
|
1454 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
|
1455 setDate(parameterIndex, (Date)x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1456 } 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
|
1457 setDate(parameterIndex, new Date(((Timestamp)x).getTime())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1458 } 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
|
1459 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
|
1460 } 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
|
1461 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
|
1462 } else { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1463 throw new SQLException("Conversion not allowed", "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1464 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1465 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1466 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
|
1467 case Types.TIME_WITH_TIMEZONE: |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1468 if (x instanceof Time) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1469 setTime(parameterIndex, (Time)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1470 } else if (x instanceof Timestamp) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1471 setTime(parameterIndex, new Time(((Timestamp)x).getTime())); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1472 } 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
|
1473 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
|
1474 } 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
|
1475 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
|
1476 } else { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1477 throw new SQLException("Conversion not allowed", "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1478 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1479 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1480 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
|
1481 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
|
1482 if (x instanceof Timestamp) { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1483 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
|
1484 } 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
|
1485 setTimestamp(parameterIndex, new Timestamp(((Date)x).getTime())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1486 } 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
|
1487 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
|
1488 } 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
|
1489 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
|
1490 } else { |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1491 throw new SQLException("Conversion not allowed", "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1492 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1493 break; |
131
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1494 case Types.CHAR: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1495 case Types.VARCHAR: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1496 case Types.LONGVARCHAR: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1497 case Types.CLOB: |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1498 setString(parameterIndex, x.toString()); |
0112d8496636
Added test program for bug 6349.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
1499 break; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1500 default: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1501 throw new SQLException("Conversion not allowed", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1502 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1503 } else if (x instanceof Array) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1504 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
|
1505 } 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
|
1506 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
|
1507 } 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
|
1508 setClob(parameterIndex, (Clob)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1509 } else if (x instanceof Ref) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1510 setRef(parameterIndex, (Ref)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1511 } else if (x instanceof java.net.URL) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1512 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
|
1513 } 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
|
1514 setString(parameterIndex, x.toString()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1515 } else if (x instanceof RowId) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1516 setRowId(parameterIndex, (RowId)x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1517 } 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
|
1518 setNClob(parameterIndex, (NClob)x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1519 } 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
|
1520 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
|
1521 } 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
|
1522 final SQLData sx = (SQLData)x; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1523 final int paramnr = parameterIndex; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1524 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
|
1525 final SQLOutput out = new SQLOutput() { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1526 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1527 public void writeString(String x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1528 // special situation, this is when a string |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1529 // 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
|
1530 // 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
|
1531 // 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
|
1532 setValue(paramnr, sqltype + " " + MonetWrapper.sq(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1533 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1536 public void writeBoolean(boolean x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1537 setBoolean(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1538 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1541 public void writeByte(byte x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1542 setByte(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1543 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1546 public void writeShort(short x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1547 setShort(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1548 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1551 public void writeInt(int x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1552 setInt(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1553 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1556 public void writeLong(long x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1557 setLong(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1558 } |
29
c26213e86442
Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1559 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1560 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1561 public void writeFloat(float x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1562 setFloat(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1563 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1566 public void writeDouble(double x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1567 setDouble(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1568 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1571 public void writeBigDecimal(BigDecimal x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1572 setBigDecimal(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1573 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1576 public void writeBytes(byte[] x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1577 setBytes(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1578 } |
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 @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
|
1581 public void writeDate(Date x) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1582 setDate(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1583 } |
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 @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
|
1586 public void writeTime(Time x) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1587 setTime(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1588 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1591 public void writeTimestamp(Timestamp x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1592 setTimestamp(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1593 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1596 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
|
1597 setCharacterStream(paramnr, x); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1598 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1601 public void writeAsciiStream(InputStream x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1602 setAsciiStream(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1603 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1606 public void writeBinaryStream(InputStream x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1607 setBinaryStream(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1608 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1611 public void writeObject(SQLData x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1612 setObject(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1613 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1616 public void writeRef(Ref x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1617 setRef(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1618 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1621 public void writeBlob(Blob x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1622 setBlob(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1623 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1626 public void writeClob(Clob x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1627 setClob(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1628 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1631 public void writeStruct(Struct x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1632 setObject(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1633 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1636 public void writeArray(Array x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1637 setArray(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1638 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1641 public void writeURL(URL x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1642 setURL(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1643 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1646 public void writeNString(String x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1647 setNString(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1648 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1649 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1650 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1651 public void writeNClob(NClob x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1652 setNClob(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1653 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1656 public void writeRowId(RowId x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1657 setRowId(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1658 } |
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 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1661 public void writeSQLXML(SQLXML x) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1662 setSQLXML(paramnr, x); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1663 } |
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 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
|
1666 } 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
|
1667 // 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
|
1668 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
|
1669 } 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
|
1670 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
|
1671 } |
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 /** |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
1675 * 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
|
1676 * 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
|
1677 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1678 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1679 * @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
|
1680 * @param x an SQL REF value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1681 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1682 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1683 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1684 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1685 @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
|
1686 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
|
1687 throw newSQLFeatureNotSupportedException("setRef"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1688 } |
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 * 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
|
1692 * 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
|
1693 * the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1694 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
1695 * @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
|
1696 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1697 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1698 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1699 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1700 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1701 @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
|
1702 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
|
1703 throw newSQLFeatureNotSupportedException("setRowId"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1704 } |
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 * 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
|
1708 * 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
|
1709 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1710 * @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
|
1711 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1712 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1713 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1714 @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
|
1715 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
|
1716 setValue(parameterIndex, Short.toString(x)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1717 } |
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 * 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
|
1721 * 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
|
1722 * 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
|
1723 * it sends it to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1724 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1725 * @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
|
1726 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1727 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1728 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1729 @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
|
1730 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
|
1731 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
|
1732 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1733 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1734 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1735 |
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
|
1736 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
|
1737 |
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 /* 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
|
1739 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
|
1740 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
|
1741 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
|
1742 |
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 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
|
1744 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
|
1745 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
|
1746 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
|
1747 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
|
1748 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
|
1749 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
|
1750 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
|
1751 { |
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
|
1752 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
|
1753 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
|
1754 // 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
|
1755 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
|
1756 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
|
1757 // 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
|
1758 // 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
|
1759 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
|
1760 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
|
1761 } 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
|
1762 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
|
1763 } |
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
|
1764 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
|
1765 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
|
1766 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
|
1767 { |
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 // 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
|
1769 // 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
|
1770 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
|
1771 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
|
1772 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
|
1773 } 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
|
1774 // 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
|
1775 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
|
1776 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
|
1777 // 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
|
1778 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
|
1779 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
|
1780 && (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
|
1781 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
|
1782 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
|
1783 } |
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 // 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
|
1785 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
|
1786 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
|
1787 && (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
|
1788 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 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
|
1790 } |
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
|
1791 |
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
|
1792 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
|
1793 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
|
1794 } 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
|
1795 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
|
1796 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
|
1797 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
|
1798 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
|
1799 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
|
1800 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
|
1801 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
|
1802 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
|
1803 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
|
1804 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
|
1805 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
|
1806 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
|
1807 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
|
1808 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
|
1809 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
|
1810 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
|
1811 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
|
1812 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
|
1813 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
|
1814 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
|
1815 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
|
1816 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
|
1817 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
|
1818 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
|
1819 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
|
1820 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
|
1821 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
|
1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 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
|
1832 // 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
|
1833 // 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
|
1834 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
|
1835 start++; |
b32946647c77
Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
426
diff
changeset
|
1836 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
|
1837 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
|
1838 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
|
1839 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
|
1840 } |
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 // 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
|
1842 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
|
1843 // 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
|
1844 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
|
1845 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
|
1846 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
|
1847 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
|
1848 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
|
1849 } |
b32946647c77
Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
426
diff
changeset
|
1850 } |
b32946647c77
Extended PreparedStatement.setString() json string validity test for json parameters to now also accept: numbers (with optional fractions and exponent), string literals between double quotes, and keywords: true, false and null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
426
diff
changeset
|
1851 // 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
|
1852 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
|
1853 // 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
|
1854 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
|
1855 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
|
1856 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
|
1857 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
|
1858 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
|
1859 } |
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 // 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
|
1861 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
|
1862 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
|
1863 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
|
1864 } |
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 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
|
1867 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
|
1868 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
|
1869 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
|
1870 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
|
1871 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
|
1872 } |
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 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
|
1876 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
|
1877 |
426
3da79315783b
Optimisation in MonetPreparedStatement.setString(int parameterIndex, String x) for when the string is not of type inet or json or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
425
diff
changeset
|
1878 castprefix = "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
|
1879 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
|
1880 } |
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
|
1881 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
|
1882 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
|
1883 // 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
|
1884 // 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
|
1885 // 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
|
1886 // 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
|
1887 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
|
1888 } 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
|
1889 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
|
1890 } |
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
|
1891 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
|
1892 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
|
1893 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
|
1894 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
|
1895 // 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
|
1896 // 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
|
1897 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
|
1898 } 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
|
1899 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
|
1900 } |
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
|
1901 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
|
1902 break; |
642
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
624
diff
changeset
|
1903 // case "xml": |
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
624
diff
changeset
|
1904 // 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
|
1905 // 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
|
1906 // 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
|
1907 } |
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
|
1908 if (castprefix != null) { |
642
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
624
diff
changeset
|
1909 /* 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
|
1910 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
|
1911 } 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
|
1912 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
|
1913 } |
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
|
1914 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
|
1915 } |
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 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
|
1917 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
|
1918 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
|
1919 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
|
1920 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
|
1921 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
|
1922 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
|
1923 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
|
1924 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
|
1925 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
|
1926 // 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
|
1927 // 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
|
1928 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
|
1929 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
|
1930 } 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
|
1931 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
|
1932 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
|
1933 } 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
|
1934 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
|
1935 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
|
1936 } 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
|
1937 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
|
1938 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
|
1939 } |
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 } 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
|
1941 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
|
1942 } |
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 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
|
1944 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
|
1945 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
|
1946 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
|
1947 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
|
1948 } 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
|
1949 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
|
1950 } |
8ea360b612de
Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
157
diff
changeset
|
1951 break; |
8ea360b612de
Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
157
diff
changeset
|
1952 case Types.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
|
1953 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
|
1954 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
|
1955 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
|
1956 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
|
1957 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
|
1958 // 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
|
1959 // 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
|
1960 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
|
1961 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
|
1962 } 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
|
1963 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
|
1964 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
|
1965 } 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
|
1966 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
|
1967 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
|
1968 } |
8ea360b612de
Corrected PreparedStatement methods setString(int, String) and setObject(int, Object, ...) in case the target parameter data type was json or inet or url or uuid.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
157
diff
changeset
|
1969 } 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
|
1970 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
|
1971 } |
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 /* 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
|
1973 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
|
1974 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
|
1975 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
|
1976 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
|
1977 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
|
1978 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
|
1979 // 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
|
1980 // 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
|
1981 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
|
1982 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
|
1983 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
|
1984 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
|
1985 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
|
1986 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
|
1987 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
|
1988 } |
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 /* 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
|
1993 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
|
1994 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
|
1995 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
|
1996 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
|
1997 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1998 } |
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 * 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
|
2002 * 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
|
2003 * sends it to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2004 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2005 * @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
|
2006 * @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
|
2007 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2008 * @throws SQLFeatureNotSupportedException the JDBC driver does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2009 * not support this method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2010 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2011 @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
|
2012 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
|
2013 throw newSQLFeatureNotSupportedException("setSQLXML"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2014 } |
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 * 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
|
2018 * 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
|
2019 * the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2020 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2021 * @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
|
2022 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2023 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2024 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2025 @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
|
2026 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
|
2027 setTime(parameterIndex, x, null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2028 } |
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 * 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
|
2032 * 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
|
2033 * 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
|
2034 * 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
|
2035 * 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
|
2036 * 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
|
2037 * 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
|
2038 * application. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2039 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2040 * @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
|
2041 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2042 * @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
|
2043 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2044 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2045 @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
|
2046 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
|
2047 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2048 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2049 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
|
2050 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2051 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2052 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2053 |
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
|
2054 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
|
2055 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
|
2056 if (hasTimeZone) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2057 // 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
|
2058 // 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
|
2059 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
|
2060 // 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
|
2061 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
|
2062 } |
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
|
2063 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
|
2064 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
|
2065 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2066 // 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
|
2067 // 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
|
2068 // 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
|
2069 // here |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2070 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
|
2071 setValue(parameterIndex, "time '" + x.toString() + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2072 } 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
|
2073 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
|
2074 // 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
|
2075 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
|
2076 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2077 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
|
2078 setValue(parameterIndex, "time '" + mTime.format(x) + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2079 } |
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 * 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
|
2085 * 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
|
2086 * it sends it to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2087 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2088 * @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
|
2089 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2090 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2091 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2092 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2093 public void setTimestamp(final int parameterIndex, final Timestamp x) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2094 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2095 { |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2096 setTimestamp(parameterIndex, x, null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2097 } |
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 * 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
|
2101 * 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
|
2102 * 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
|
2103 * 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
|
2104 * 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
|
2105 * 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
|
2106 * 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
|
2107 * the application. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2108 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2109 * @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
|
2110 * @param x the parameter value |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2111 * @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
|
2112 * timestamp |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2113 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2114 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2115 @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
|
2116 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
|
2117 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2118 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2119 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
|
2120 setValue(parameterIndex, "NULL"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2121 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2122 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2123 |
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
|
2124 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
|
2125 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
|
2126 if (hasTimeZone) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2127 // 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
|
2128 // 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
|
2129 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
|
2130 // 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
|
2131 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
|
2132 } |
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
|
2133 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
|
2134 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
|
2135 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2136 // 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
|
2137 // 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
|
2138 // 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
|
2139 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
|
2140 setValue(parameterIndex, "timestamp '" + x.toString() + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2141 } 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
|
2142 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
|
2143 // 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
|
2144 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
|
2145 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2146 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
|
2147 setValue(parameterIndex, "timestamp '" + mTimestamp.format(x) + "'"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2148 } |
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 * 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
|
2154 * 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
|
2155 * 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
|
2156 * 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
|
2157 * 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
|
2158 * 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
|
2159 * 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
|
2160 * 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
|
2161 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2162 * 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
|
2163 * your own subclass that implements the standard interface. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2164 * |
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
|
2165 * @deprecated Use setCharacterStream |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2166 * @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
|
2167 * @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
|
2168 * parameter value as two-byte Unicode characters |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2169 * @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
|
2170 * @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
|
2171 * @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
|
2172 * not support this method |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2173 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2174 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2175 @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
|
2176 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
|
2177 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2178 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2179 throw newSQLFeatureNotSupportedException("setUnicodeStream"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2180 } |
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 * 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
|
2184 * 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
|
2185 * database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2186 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2187 * @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
|
2188 * @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
|
2189 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2190 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2191 @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
|
2192 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
|
2193 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
|
2194 setValue(parameterIndex, "NULL"); |
156
2abd488159c4
Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
155
diff
changeset
|
2195 return; |
2abd488159c4
Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
155
diff
changeset
|
2196 } |
2abd488159c4
Implemented PreparedStatement method setURL(int, URL).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
155
diff
changeset
|
2197 |
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
|
2198 setValue(parameterIndex, "url " + MonetWrapper.sq(x.toString())); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2199 } |
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 * Releases this PreparedStatement object's database and JDBC |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2203 * 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
|
2204 * 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
|
2205 * 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
|
2206 * 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
|
2207 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2208 * 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
|
2209 * 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
|
2210 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2211 * <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
|
2212 * 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
|
2213 * 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
|
2214 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2215 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2216 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
|
2217 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
|
2218 try { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2219 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
|
2220 } 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
|
2221 // 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
|
2222 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2223 } |
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
|
2224 clearParameters(); |
717
7240d2dd369f
Improved implementation of PreparedStatement.getMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
2225 rsmd = null; |
719
2f42195e9c58
Improved implementation of PreparedStatement.getParameterMetaData().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
717
diff
changeset
|
2226 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
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 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
|
2232 execStmt = null; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2233 super.close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2234 } |
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 /** |
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
|
2237 * 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
|
2238 * |
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 * @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
|
2240 */ |
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
|
2241 @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
|
2242 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
|
2243 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
|
2244 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
|
2245 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
|
2246 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
|
2247 /* 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
|
2248 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
|
2249 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
|
2250 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
|
2251 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
|
2252 } |
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 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
|
2255 } |
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 |
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
|
2257 //== 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
|
2258 |
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 @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
|
2260 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
|
2261 // 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
|
2262 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
|
2263 } |
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 @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
|
2266 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
|
2267 // 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
|
2268 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
|
2269 } |
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 * 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
|
2273 * 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
|
2274 * 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
|
2275 * |
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 * 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
|
2277 * 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
|
2278 * |
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 * @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
|
2280 * 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
|
2281 * @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
|
2282 * 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
|
2283 */ |
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 @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
|
2285 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
|
2286 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
|
2287 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
|
2288 |
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 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
|
2290 } |
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 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2292 //== end methods interface PreparedStatement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2293 |
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
|
2294 |
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 //== 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
|
2296 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2297 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2298 * 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
|
2299 * 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
|
2300 * never be null. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2301 * |
154
9a026aa272bb
Comply with the JDBC spec by using argument name: parameterIndex
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
2302 * @param parameterIndex the parameter index |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2303 * @param val the exact String representation to set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2304 * @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
|
2305 */ |
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
|
2306 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
|
2307 if (parameterIndex < 1 || parameterIndex > paramCount) |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2308 throw new SQLException("No such parameter with index: " + parameterIndex, "M1M05"); |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2309 |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2310 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
|
2311 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
|
2312 else |
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2313 paramValues[parameterIndex] = "NULL"; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2314 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2315 |
708
5022a57f9d97
Resolve javadoc errors.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
696
diff
changeset
|
2316 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
|
2317 /** |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2318 * 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
|
2319 * 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
|
2320 * |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2321 * @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
|
2322 * @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
|
2323 */ |
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
|
2324 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
|
2325 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
|
2326 // 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
|
2327 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
|
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 execStmt.setLength(0); // clear the buffer |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2330 |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2331 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
|
2332 // 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
|
2333 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
|
2334 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
|
2335 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
|
2336 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
|
2337 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
|
2338 execStmt.append(paramValues[param]); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2339 } |
473
6a6c86ac3232
Optimised storing, setting and processing of parameter values in MonetPreparedStatement.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
451
diff
changeset
|
2340 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
|
2341 return execStmt.toString(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2342 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2343 } |