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

Optimisation, call connection.mapClobAsVarChar() and connection.mapBlobAsVarBinary() outside the for-loop, as it does not change.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 10 Apr 2025 19:26:59 +0200 (3 hours ago)
parents 5cc071c5c170
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1 /*
833
e890195256ac Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents: 819
diff changeset
2 * SPDX-License-Identifier: MPL-2.0
e890195256ac Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents: 819
diff changeset
3 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
4 * This Source Code Form is subject to the terms of the Mozilla Public
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
7 *
937
d416e9b6b3d0 Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 927
diff changeset
8 * Copyright 2024, 2025 MonetDB Foundation;
833
e890195256ac Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents: 819
diff changeset
9 * Copyright August 2008 - 2023 MonetDB B.V.;
e890195256ac Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents: 819
diff changeset
10 * Copyright 1997 - July 2008 CWI.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
11 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
12
391
f523727db392 Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 378
diff changeset
13 package org.monetdb.jdbc;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
14
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: 378
diff changeset
15 import org.monetdb.mcl.net.MapiSocket;
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
16 import java.sql.BatchUpdateException;
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
17 import java.sql.Connection;
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
18 import java.sql.Statement;
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
19 import java.sql.ResultSet;
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
20 import java.sql.SQLException;
179
f0a704e33fe4 Improvement: throw SQLFeatureNotSupportedException instead of SQLException
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 164
diff changeset
21 import java.sql.SQLFeatureNotSupportedException;
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
22 import java.sql.SQLWarning;
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
23 import java.util.ArrayList;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
24 import java.util.concurrent.locks.ReentrantLock;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
25
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
26 /**
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: 414
diff changeset
27 *<pre>
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 414
diff changeset
28 * A {@link Statement} suitable for the MonetDB database.
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
29 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
30 * The object used for executing a static SQL statement and returning
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: 414
diff changeset
31 * the result(s) it produces.
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
32 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
33 * By default, only one {@link ResultSet} object per Statement object can be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
34 * open at the same time. Therefore, if the reading of one ResultSet
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
35 * object is interleaved with the reading of another, each must have
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: 414
diff changeset
36 * been generated by different {@link Statement} objects. All execution
3dfcd06fd8ba Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 414
diff changeset
37 * methods in the Statement interface implicitly close a Statement's current
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
38 * ResultSet object if an open one exists.
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
39 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
40 * The current state of this Statement is that it only implements the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
41 * executeQuery() which returns a ResultSet where from results can be
259
1485870ae208 Improve comment text and resolve 4 javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 250
diff changeset
42 * read and executeUpdate() which returns the affected rows for DML.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
43 * Commit and rollback are implemented, as is the autoCommit mechanism
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
44 * which relies on server side auto commit.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
45 * Multi-result queries are supported using the getMoreResults() method.
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: 414
diff changeset
46 *</pre>
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
47 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
48 * @author Fabian Groffen
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
49 * @author Martin van Dinther
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: 361
diff changeset
50 * @version 0.9
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
51 */
164
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
52 public class MonetStatement
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
53 extends MonetWrapper
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
54 implements Statement, AutoCloseable
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
55 {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
56 /** The parental Connection object */
286
d430f8adbf1b Add keyword "final" to those variables which do not change after first assigment.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 261
diff changeset
57 protected final MonetConnection connection;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
58 /** The last ResponseList object this Statement produced */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
59 private MonetConnection.ResponseList lastResponseList;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
60 /** The last Response that this object uses */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
61 MonetConnection.Response header;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
62 /** The warnings this Statement object generated */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
63 private SQLWarning warnings;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
64 /** Whether this Statement object is closed or not */
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
65 protected boolean closed = false;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
66 /** Whether the application wants this Statement object to be pooled */
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
67 protected boolean poolable = false;
249
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
68 /** Whether this Statement should be closed if the last ResultSet closes */
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
69 private boolean closeOnCompletion = false;
249
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
70 /** The timeout (in sec) for the query to return, 0 means no timeout */
408
5540793628d6 Improve code when setting query timeout. It used to call the sys.settimeout(bigint) which is deprecated as of release Jun2020 (11.37.7) and replaced by new sys.setquerytimeout(int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
71 private int queryTimeout;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
72 /** The size of the blocks of results to ask for at the server */
408
5540793628d6 Improve code when setting query timeout. It used to call the sys.settimeout(bigint) which is deprecated as of release Jun2020 (11.37.7) and replaced by new sys.setquerytimeout(int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
73 private int fetchSize;
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: 361
diff changeset
74 /** The maximum number of rows to return in a ResultSet, 0 indicates unlimited */
408
5540793628d6 Improve code when setting query timeout. It used to call the sys.settimeout(bigint) which is deprecated as of release Jun2020 (11.37.7) and replaced by new sys.setquerytimeout(int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
75 private long maxRows;
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
76 /** The type of ResultSet to produce; i.e. forward only, random access */
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
77 private int resultSetType = MonetResultSet.DEF_RESULTSETTYPE;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
78 /** The suggested direction of fetching data (implemented but not used) */
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
79 private int fetchDirection = MonetResultSet.DEF_FETCHDIRECTION;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
80 /** The concurrency of the ResultSet to produce */
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
81 private int resultSetConcurrency = MonetResultSet.DEF_CONCURRENCY;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
82
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
83 /** A List to hold all queries of a batch */
408
5540793628d6 Improve code when setting query timeout. It used to call the sys.settimeout(bigint) which is deprecated as of release Jun2020 (11.37.7) and replaced by new sys.setquerytimeout(int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
84 private ArrayList<String> batch;
5540793628d6 Improve code when setting query timeout. It used to call the sys.settimeout(bigint) which is deprecated as of release Jun2020 (11.37.7) and replaced by new sys.setquerytimeout(int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
85 private ReentrantLock batchLock;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
86
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
87
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
88 /**
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
89 * MonetStatement constructor which checks the arguments for validity.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
90 * This constructor is only accessible to classes from the jdbc package.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
91 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
92 * @param connection the connection that created this Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
93 * @param resultSetType type of ResultSet to produce
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
94 * @param resultSetConcurrency concurrency of ResultSet to produce
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
95 * @param resultSetHoldability holdability of ResultSet after commit
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
96 * @throws SQLException if an error occurs during login
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
97 * @throws IllegalArgumentException is one of the arguments null or empty
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
98 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
99 MonetStatement(
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
100 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
101 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
102 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
103 final int resultSetHoldability)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
104 throws SQLException, IllegalArgumentException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
105 {
164
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
106 if (connection == null)
7c9e386fe49a As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 90
diff changeset
107 throw new IllegalArgumentException("No Connection given!");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
108
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
109 this.connection = connection;
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
110 this.queryTimeout = connection.lastSetQueryTimeout;
696
07d60185eeb9 Eliminate hardcoded value 250 in the constructor of MonetPreparedStatement. For this an internal package method MonetConnection.getDefaultFetchSize() is added.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 692
diff changeset
111 this.fetchSize = connection.getDefaultFetchSize();
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
112
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
113 this.resultSetType = resultSetType;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
114 this.resultSetConcurrency = resultSetConcurrency;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
115
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
116 // check our limits, and generate warnings as appropriate
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
117 if (this.resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
118 addWarning("No concurrency mode other then read only is supported, continuing with concurrency level READ_ONLY", "01M13");
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 this.resultSetConcurrency = ResultSet.CONCUR_READ_ONLY;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
120 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
121
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
122 // check type for supported mode
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
123 if (this.resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
124 addWarning("Change sensitive scrolling ResultSet objects are not supported, continuing with a change non-sensitive scrollable cursor.", "01M14");
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
125 this.resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
126 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
127
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
128 // check type for supported holdability
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
129 if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
292
b127164342c4 Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 291
diff changeset
130 addWarning("Close cursors at commit not supported, continuing with holdability to hold cursors open over commit.", "01M15");
0
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 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
133
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
134 //== methods of interface Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
135
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
136 /**
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
137 * Adds the given SQL command to the current list of commands for this
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
138 * Statement object. The commands in this list can be executed as a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
139 * batch by calling the method executeBatch.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
140 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
141 * @param sql typically this is a static SQL INSERT or UPDATE statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
142 * @throws SQLException so the PreparedStatement can throw this exception
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
143 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
144 @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
145 public void addBatch(final String sql) throws SQLException {
692
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
146 if (sql == null || sql.isEmpty())
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
147 throw new SQLException("Missing SQL statement", "M1M05");
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
148
290
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
149 if (batch == null) {
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
150 // create the ArrayList at first time use
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
151 batch = new ArrayList<String>();
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
152 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
153 batch.add(sql);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
154 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
155
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
156 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
157 * Empties this Statement object's current list of SQL commands.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
158 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
159 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
160 public void clearBatch() {
290
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
161 if (batch != null)
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
162 batch.clear();
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
163 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
164
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
165 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
166 * Submits a batch of commands to the database for execution and if
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
167 * all commands execute successfully, returns an array of update
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
168 * counts. The int elements of the array that is returned are
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
169 * ordered to correspond to the commands in the batch, which are
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
170 * ordered according to the order in which they were added to the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
171 * batch. The elements in the array returned by the method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
172 * executeBatch may be one of the following:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
173 * <ol>
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
174 * <li>A number greater than or equal to zero -- indicates that the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
175 * command was processed successfully and is an update count giving
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
176 * the number of rows in the database that were affected by the
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
177 * command's execution
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
178 * <li>A value of SUCCESS_NO_INFO -- indicates that the command was
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
179 * processed successfully but that the number of rows affected is unknown
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
180 * <p>If one of the commands in a batch update fails to execute properly,
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
181 * this method throws a BatchUpdateException, and a JDBC driver may or
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
182 * may not continue to process the remaining commands in the batch.
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
183 * However, the driver's behavior must be consistent with a particular DBMS,
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
184 * either always continuing to process commands or never continuing to process
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
185 * commands. If the driver continues processing after a failure, the array
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
186 * returned by the method BatchUpdateException.getUpdateCounts will
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
187 * contain as many elements as there are commands in the batch, and at
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
188 * least one of the elements will be the following:</p>
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
189 * <li>A value of EXECUTE_FAILED -- indicates that the command failed to
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
190 * execute successfully and occurs only if a driver continues to process
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
191 * commands after a command fails
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
192 * </ol>
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
193 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
194 * MonetDB does continues after an error has occurred in the batch.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
195 * If one of the commands attempts to return a result set, an
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
196 * SQLException is added to the SQLException list and thrown
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
197 * afterwards execution. Failing queries result in SQLExceptions
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
198 * too and may cause subparts of the batch to fail as well.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
199 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
200 * @return an array of update counts containing one element for each
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
201 * command in the batch. The elements of the array are ordered
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
202 * according to the order in which commands were added to the batch.
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
203 * @throws SQLException if a database access error occurs.
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
204 * @throws BatchUpdateException (a subclass of SQLException) if one of the
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
205 * commands sent to the database fails to execute properly.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
206 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
207 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
208 public int[] executeBatch() throws SQLException {
290
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
209 if (batch == null || batch.isEmpty()) {
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
210 return new int[0];
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
211 }
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
212
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
213 final long[] ret = executeLargeBatch();
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
214 // copy contents of long[] into new int[]
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
215 final int[] counts = new int[ret.length];
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
216 for (int i = 0; i < ret.length; i++) {
480
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
217 if (ret[i] >= Integer.MAX_VALUE)
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
218 counts[i] = Integer.MAX_VALUE;
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
219 else
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
220 counts[i] = (int)ret[i];
290
d477b3103a8b Optimised MonetStatement memory resource usage by only creating an ArrayList and ReentrantLock object when the batch methods addBatch() or executeBatch() are called. In most Statement usages those methods are not called.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 286
diff changeset
221 }
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
222 return counts;
0
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
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
225 /**
181
237816fef586 Correct the documentation of the cancel() method.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 179
diff changeset
226 * Cancels this Statement object if both the DBMS and driver support aborting an SQL statement.
237816fef586 Correct the documentation of the cancel() method.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 179
diff changeset
227 * This method can be used by one thread to cancel a statement that is being executed by another thread.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
228 *
181
237816fef586 Correct the documentation of the cancel() method.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 179
diff changeset
229 * @throws SQLException - if a database access error occurs or this method is called on a closed Statement
179
f0a704e33fe4 Improvement: throw SQLFeatureNotSupportedException instead of SQLException
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 164
diff changeset
230 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
231 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
232 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
233 public void cancel() throws SQLException {
179
f0a704e33fe4 Improvement: throw SQLFeatureNotSupportedException instead of SQLException
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 164
diff changeset
234 throw new SQLFeatureNotSupportedException("Query cancelling is currently not supported by the driver.", "0A000");
927
d311affc65f0 Stop referring to monetdb.org/bugzilla, point straight to github.
Sjoerd Mullender <sjoerd@acm.org>
parents: 833
diff changeset
235 // a request to implement this is already logged, see: https://github.com/MonetDB/MonetDB/issues/6222
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
236 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
237
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 * Clears all warnings reported for this Statement object. After a call to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
240 * this method, the method getWarnings returns null until a new warning is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
241 * reported for this Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
242 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
243 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
244 public void clearWarnings() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
245 warnings = null;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
246 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
247
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
248 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
249 * Releases this Statement object's database and JDBC resources immediately
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
250 * instead of waiting for this to happen when it is automatically closed. It
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
251 * is generally good practice to release resources as soon as you are
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
252 * finished with them to avoid tying up database resources.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
253 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
254 * Calling the method close on a Statement object that is already closed has
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
255 * no effect.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
256 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
257 * A Statement object is automatically closed when it is garbage collected.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
258 * When a Statement object is closed, its current ResultSet object, if one
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
259 * exists, is also closed.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
260 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
261 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
262 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
263 clearBatch();
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
264 clearWarnings();
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
265 // close previous ResultSet, if not closed already
183
57f09396b22c Small improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 181
diff changeset
266 if (lastResponseList != null) {
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
267 lastResponseList.close();
183
57f09396b22c Small improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 181
diff changeset
268 lastResponseList = null;
57f09396b22c Small improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 181
diff changeset
269 }
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
270 header = 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
271 batchLock = null;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
272 closed = true;
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 // Chapter 13.1.2.3 of Sun's JDBC 3.0 Specification
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
276 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
277 * Executes the given SQL statement, which may return multiple results. In
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
278 * some (uncommon) situations, a single SQL statement may return multiple
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
279 * result sets and/or update counts. Normally you can ignore this unless
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
280 * you are (1) executing a stored procedure that you know may return
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
281 * multiple results or (2) you are dynamically executing an unknown SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
282 * string.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
283 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
284 * The execute method executes an SQL statement and indicates the form of
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
285 * the first result. You must then use the methods getResultSet or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
286 * getUpdateCount to retrieve the result, and getMoreResults to move to any
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
287 * subsequent result(s).
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
288 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
289 * @param sql any SQL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
290 * @return true if the first result is a ResultSet object; false if it is an
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
291 * update count or there are no results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
292 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
293 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
294 @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
295 public boolean execute(final String sql) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
296 return internalExecute(sql);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
297 }
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
298
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
299 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
300 * Executes the given SQL statement, which may return multiple
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
301 * results, and signals the driver that any auto-generated keys
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
302 * should be made available for retrieval. The driver will ignore
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
303 * this signal if the SQL statement is not an INSERT statement.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
304 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
305 * In some (uncommon) situations, a single SQL statement may return
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
306 * multiple result sets and/or update counts. Normally you can
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
307 * ignore this unless you are (1) executing a stored procedure that
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
308 * you know may return multiple results or (2) you are dynamically
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
309 * executing an unknown SQL string.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
310 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
311 * The execute method executes an SQL statement and indicates the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
312 * form of the first result. You must then use the methods
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
313 * getResultSet or getUpdateCount to retrieve the result, and
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
314 * getMoreResults to move to any subsequent result(s).
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
315 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
316 * @param sql any SQL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
317 * @param autoGeneratedKeys a constant indicating whether
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
318 * auto-generated keys should be made available for retrieval
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
319 * using the method getGeneratedKeys; one of the following
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
320 * constants: Statement.RETURN_GENERATED_KEYS or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
321 * Statement.NO_GENERATED_KEYS
259
1485870ae208 Improve comment text and resolve 4 javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 250
diff changeset
322 * @return true if the first result is a ResultSet object; false if
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
323 * it is an update count or there are no results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
324 * @throws SQLException - if a database access error occurs or the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
325 * second parameter supplied to this method is not
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
326 * Statement.RETURN_GENERATED_KEYS or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
327 * Statement.NO_GENERATED_KEYS.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
328 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
329 @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
330 public boolean execute(final String sql, final int autoGeneratedKeys)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
331 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
332 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
333 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS &&
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
334 autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
335 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05");
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
336
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
337 /* MonetDB has no way to disable this, so just do the normal thing ;) */
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
338 return internalExecute(sql);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
339 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
340
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 * Executes the given SQL statement, which may return multiple
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
343 * results, and signals the driver that the auto-generated keys
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
344 * indicated in the given array should be made available for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
345 * retrieval. This array contains the indexes of the columns in the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
346 * target table that contain the auto-generated keys that should be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
347 * made available. The driver will ignore the array if the given SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
348 * statement is not an INSERT statement.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
349 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
350 * Under some (uncommon) situations, a single SQL statement may
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
351 * return multiple result sets and/or update counts. Normally you
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
352 * can ignore this unless you are (1) executing a stored procedure
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
353 * that you know may return multiple results or (2) you are
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
354 * dynamically executing an unknown SQL string.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
355 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
356 * The execute method executes an SQL statement and indicates the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
357 * form of the first result. You must then use the methods
259
1485870ae208 Improve comment text and resolve 4 javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 250
diff changeset
358 * getResultSet or getUpdateCount to retrieve the result, and
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
359 * getMoreResults to move to any subsequent result(s).
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
360 *
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
361 * MonetDB only supports returning the generated key for one column,
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
362 * which will be the first column that has a serial. Hence, this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
363 * method cannot work as required and the driver will fall back to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
364 * executing with request to the database to return the generated
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
365 * key, if any.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
366 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
367 * @param sql any SQL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
368 * @param columnIndexes an array of the indexes of the columns in
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
369 * the inserted row that should be made available for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
370 * retrieval by a call to the method getGeneratedKeys
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
371 * @return true if the first result is a ResultSet object; false if
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
372 * it is an update count or there are no results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
373 * @throws SQLException if a database access error occurs or the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
374 * elements in the int array passed to this method are not
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
375 * valid column indexes
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
376 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
377 @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
378 public boolean execute(final String sql, final int[] columnIndexes)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
379 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
380 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
381 addWarning("execute: generated keys for fixed set of columns not supported", "01M18");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
382 return execute(sql, Statement.RETURN_GENERATED_KEYS);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
383 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
384
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
385 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
386 * Executes the given SQL statement, which may return multiple
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
387 * results, and signals the driver that the auto-generated keys
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
388 * indicated in the given array should be made available for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
389 * retrieval. This array contains the names of the columns in the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
390 * target table that contain the auto-generated keys that should be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
391 * made available. The driver will ignore the array if the given SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
392 * statement is not an INSERT statement.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
393 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
394 * In some (uncommon) situations, a single SQL statement may return
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
395 * multiple result sets and/or update counts. Normally you can
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
396 * ignore this unless you are (1) executing a stored procedure that
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
397 * you know may return multiple results or (2) you are dynamically
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
398 * executing an unknown SQL string.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
399 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
400 * The execute method executes an SQL statement and indicates the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
401 * form of the first result. You must then use the methods
259
1485870ae208 Improve comment text and resolve 4 javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 250
diff changeset
402 * getResultSet or getUpdateCount to retrieve the result, and
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
403 * getMoreResults to move to any subsequent result(s).
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
404 *
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
405 * MonetDB only supports returning the generated key for one column,
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
406 * which will be the first column that has a serial. Hence, this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
407 * method cannot work as required and the driver will fall back to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
408 * executing with request to the database to return the generated
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
409 * key, if any.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
410 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
411 * @param sql any SQL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
412 * @param columnNames an array of the names of the columns in the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
413 * inserted row that should be made available for retrieval
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
414 * by a call to the method getGeneratedKeys
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
415 * @return true if the next result is a ResultSet object; false if
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
416 * it is an update count or there are no more results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
417 * @throws SQLException if a database access error occurs or the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
418 * elements of the String array passed to this method are
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
419 * not valid column names
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
420 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
421 @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
422 public boolean execute(final String sql, final String[] columnNames)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
423 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
424 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
425 addWarning("execute: generated keys for fixed set of columns not supported", "01M18");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
426 return execute(sql, Statement.RETURN_GENERATED_KEYS);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
427 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
428
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
429 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
430 * Performs the steps to execute a given SQL statement. This method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
431 * exists to allow the functionality of this function to be called
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
432 * from within this class only. The PreparedStatement for example
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
433 * overrides the execute() method to throw an SQLException, but it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
434 * needs its functionality when the executeBatch method (which is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
435 * inherited) is called.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
436 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
437 * @param sql any SQL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
438 * @return true if the first result is a ResultSet object; false if
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
439 * it is an update count or there are no results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
440 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
441 */
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
442 private boolean internalExecute(final String sql) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
443 // close previous query, if not closed already
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
444 if (lastResponseList != null) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
445 lastResponseList.close();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
446 lastResponseList = null;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
447 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
448
692
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
449 if (sql == null || sql.isEmpty())
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
450 throw new SQLException("Missing SQL statement", "M1M05");
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
451
249
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
452 if (queryTimeout != connection.lastSetQueryTimeout) {
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
453 // set requested/changed queryTimeout on the server side first
408
5540793628d6 Improve code when setting query timeout. It used to call the sys.settimeout(bigint) which is deprecated as of release Jun2020 (11.37.7) and replaced by new sys.setquerytimeout(int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 406
diff changeset
454 connection.setQueryTimeout(queryTimeout);
249
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
455 }
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
456
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
457 // create a container for the result
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
458 lastResponseList = connection.new ResponseList(
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
459 fetchSize,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
460 maxRows,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
461 resultSetType,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
462 resultSetConcurrency
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
463 );
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
464 // fill the header list by processing the query
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
465 lastResponseList.processQuery(sql);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
466
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
467 return getMoreResults();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
468 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
469
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
470 /**
625
b32999570f4d executeUpdate(sql) and executeLargeUpdate(sql) expect a Statement, not a Query. Improved the text of the Exception msg.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
471 * Executes the given SQL query, which returns a single ResultSet object.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
472 *
625
b32999570f4d executeUpdate(sql) and executeLargeUpdate(sql) expect a Statement, not a Query. Improved the text of the Exception msg.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
473 * @param sql an SQL query statement to be sent to the database, typically a
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
474 * static SQL SELECT statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
475 * @return a ResultSet object that contains the data produced by the given
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
476 * query; never null
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
477 * @throws SQLException if a database access error occurs or the given SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
478 * statement produces anything other than a single ResultSet object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
479 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
480 @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
481 public ResultSet executeQuery(final String sql) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
482 if (execute(sql) != true)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
483 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
484
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
485 return getResultSet();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
486 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
487
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 * Executes the given SQL statement, which may be an INSERT, UPDATE, or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
490 * DELETE statement or an SQL statement that returns nothing, such as an
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
491 * SQL DDL statement.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
492 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
493 * @param sql an SQL INSERT, UPDATE or DELETE statement or an SQL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
494 * that returns nothing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
495 * @return either the row count for INSERT, UPDATE or DELETE statements, or
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
496 * 0 for SQL statements that return nothing
0
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 or the given SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
498 * statement produces a ResultSet object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
499 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
500 @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
501 public int executeUpdate(final String sql) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
502 if (execute(sql) != false)
625
b32999570f4d executeUpdate(sql) and executeLargeUpdate(sql) expect a Statement, not a Query. Improved the text of the Exception msg.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
503 throw new SQLException("Statement produced a result set", "M1M17");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
504
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
505 return Math.max(getUpdateCount(), 0);
0
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
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
508 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
509 * Executes the given SQL statement and signals the driver with the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
510 * given flag about whether the auto-generated keys produced by this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
511 * Statement object should be made available for retrieval.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
512 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
513 * @param sql must be an SQL INSERT, UPDATE or DELETE statement or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
514 * an SQL statement that returns nothing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
515 * @param autoGeneratedKeys - a flag indicating whether
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
516 * auto-generated keys should be made available for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
517 * retrieval; one of the following constants:
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
518 * Statement.RETURN_GENERATED_KEYS
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
519 * Statement.NO_GENERATED_KEYS
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
520 * @return either the row count for INSERT, UPDATE or DELETE
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
521 * statements, or 0 for SQL statements that return nothing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
522 * @throws SQLException if a database access error occurs, the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
523 * given SQL statement returns a ResultSet object, or the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
524 * given constant is not one of those allowed
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
525 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
526 @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
527 public int executeUpdate(final String sql, final int autoGeneratedKeys)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
528 throws SQLException
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 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS &&
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
531 autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
532 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05");
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
533
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
534 /* MonetDB has no way to disable this, so just do the normal thing ;) */
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
535 if (execute(sql) != false)
625
b32999570f4d executeUpdate(sql) and executeLargeUpdate(sql) expect a Statement, not a Query. Improved the text of the Exception msg.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
536 throw new SQLException("Statement produced a result set", "M1M17");
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
537
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
538 return Math.max(getUpdateCount(), 0);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
539 }
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 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
542 * Executes the given SQL statement and signals the driver that the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
543 * auto-generated keys indicated in the given array should be made
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
544 * available for retrieval. The driver will ignore the array if the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
545 * SQL statement is not an INSERT statement.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
546 *
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
547 * MonetDB only supports returning the generated key for one column,
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
548 * which will be the first column that has a serial. Hence, this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
549 * method cannot work as required and the driver will fall back to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
550 * executing with request to the database to return the generated
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
551 * key, if any.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
552 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
553 * @param sql an SQL INSERT, UPDATE or DELETE statement or an SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
554 * statement that returns nothing, such as an SQL DDL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
555 * @param columnIndexes an array of column indexes indicating the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
556 * columns that should be returned from the inserted row
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
557 * @return either the row count for INSERT, UPDATE, or DELETE
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
558 * statements, or 0 for SQL statements that return nothing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
559 * @throws SQLException if a database access error occurs, the SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
560 * statement returns a ResultSet object, or the second
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
561 * argument supplied to this method is not an int array
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
562 * whose elements are valid column indexes
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
563 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
564 @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
565 public int executeUpdate(final String sql, final int[] columnIndexes)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
566 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
567 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
568 addWarning("executeUpdate: generated keys for fixed set of columns not supported", "01M18");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
569 return executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
570 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
571
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
572 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
573 * Executes the given SQL statement and signals the driver that the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
574 * auto-generated keys indicated in the given array should be made
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
575 * available for retrieval. The driver will ignore the array if the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
576 * SQL statement is not an INSERT statement.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
577 *
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
578 * MonetDB only supports returning the generated key for one column,
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
579 * which will be the first column that has a serial. Hence, this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
580 * method cannot work as required and the driver will fall back to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
581 * executing with request to the database to return the generated
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
582 * key, if any.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
583 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
584 * @param sql an SQL INSERT, UPDATE or DELETE statement or an SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
585 * statement that returns nothing, such as an SQL DDL statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
586 * @param columnNames an array of the names of the columns that
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
587 * should be returned from the inserted row
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
588 * @return either the row count for INSERT, UPDATE, or DELETE
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
589 * statements, or 0 for SQL statements that return nothing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
590 * @throws SQLException if a database access error occurs, the SQL
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
591 * statement returns a ResultSet object, or the second
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
592 * argument supplied to this method is not a String array
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
593 * whose elements are valid column names
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
594 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
595 @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
596 public int executeUpdate(final String sql, final String[] columnNames)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
597 throws SQLException
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
598 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
599 addWarning("executeUpdate: generated keys for fixed set of columns not supported", "01M18");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
600 return executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
601 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
602
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
603 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
604 * Retrieves the Connection object that produced this Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
605 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
606 * @return the connection that produced this statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
607 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
608 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
609 public Connection getConnection() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
610 return connection;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
611 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
612
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
613 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
614 * Retrieves the direction for fetching rows from database tables that is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
615 * the default for result sets generated from this Statement object. If
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
616 * this Statement object has not set a fetch direction by calling the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
617 * method setFetchDirection, the return value is ResultSet.FETCH_FORWARD.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
618 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
619 * @return the default fetch direction for result sets generated from this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
620 * Statement object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
621 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
622 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
623 public int getFetchDirection() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
624 return fetchDirection;
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
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
627 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
628 * Retrieves the number of result set rows that is the default fetch size
696
07d60185eeb9 Eliminate hardcoded value 250 in the constructor of MonetPreparedStatement. For this an internal package method MonetConnection.getDefaultFetchSize() is added.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 692
diff changeset
629 * for ResultSet objects generated from this Statement object.
07d60185eeb9 Eliminate hardcoded value 250 in the constructor of MonetPreparedStatement. For this an internal package method MonetConnection.getDefaultFetchSize() is added.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 692
diff changeset
630 * If this Statement object has not set a fetch size by calling the
07d60185eeb9 Eliminate hardcoded value 250 in the constructor of MonetPreparedStatement. For this an internal package method MonetConnection.getDefaultFetchSize() is added.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 692
diff changeset
631 * method setFetchSize, the return value is implementation-specific.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
632 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
633 * @return the default fetch size for result sets generated from this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
634 * Statement object
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 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
637 public int getFetchSize() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
638 return fetchSize;
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
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
641 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
642 * Retrieves any auto-generated keys created as a result of
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
643 * executing this Statement object. If this Statement object did not
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
644 * generate any keys, an empty ResultSet object is returned.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
645 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
646 * @return a ResultSet object containing the auto-generated key(s)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
647 * generated by the execution of this Statement object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
648 * @throws SQLException - if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
649 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
650 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
651 public ResultSet getGeneratedKeys() throws SQLException {
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
652 final String[] columns, types;
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
653 final String[][] results;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
654
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
655 columns = new String[1];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
656 types = new String[1];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
657
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
658 columns[0] = "GENERATED_KEY";
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
659 /* the generated key should be an integer, because (wait for it) other
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
660 * frameworks such as spring expect this. */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
661 types[0] = "BIGINT";
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
662
260
d3d466182d65 Prevent NullPointerExceptions to be thrown when header == null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 259
diff changeset
663 if (header != null && header instanceof MonetConnection.UpdateResponse) {
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
664 final String lastid = ((MonetConnection.UpdateResponse)header).lastid;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
665 if (lastid.equals("-1")) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
666 results = new String[0][1];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
667 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
668 results = new String[1][1];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
669 results[0][0] = lastid;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
670 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
671 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
672 results = new String[0][1];
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
673 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
674
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
675 try {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
676 return new MonetVirtualResultSet(this, columns, types, results);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
677 } catch (IllegalArgumentException e) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
678 throw new SQLException("Internal driver error: " + e.getMessage(), "M0M03");
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 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
681
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
682 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
683 * Retrieves the maximum number of bytes that can be returned for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
684 * character and binary column values in a ResultSet object produced
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
685 * by this Statement object. This limit applies only to BINARY,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
686 * VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
687 * columns. If the limit is exceeded, the excess data is silently
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
688 * discarded.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
689 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
690 * @return the current column size limit for columns storing
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
691 * character and binary values; zero means there is no limit
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
692 * @see #setMaxFieldSize(int max)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
693 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
694 @Override
250
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
695 public int getMaxFieldSize() {
817
93b256bf29a7 Fix arithmetic overflow
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 814
diff changeset
696 return 0x7ffffffe; // MonetDB supports null terminated strings of max 2GB, see function: int UTF8_strlen()
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
697 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
698
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
699 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
700 * Retrieves the maximum number of rows that a ResultSet object produced by
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
701 * this Statement object can contain. If this limit is exceeded, the excess
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
702 * rows are silently dropped.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
703 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
704 * @return the current maximum number of rows for a ResultSet object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
705 * produced by this Statement object; zero means there is no limit
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
706 * @see #setMaxRows(int max)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
707 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
708 @Override
250
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
709 public int getMaxRows() {
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: 361
diff changeset
710 if (maxRows >= 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: 361
diff changeset
711 return 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: 361
diff changeset
712 return (int)maxRows;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
713 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
714
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 * Moves to this Statement object's next result, returns true if it is a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
717 * ResultSet object, and implicitly closes any current ResultSet object(s)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
718 * obtained with the method getResultSet.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
719 *
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
720 * There are no more results when the following is true:
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
721 * (!getMoreResults() &amp;&amp; (getUpdateCount() == -1)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
722 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
723 * @return true if the next result is a ResultSet object; false if it is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
724 * an update count or there are no more results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
725 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
726 * @see #getMoreResults(int current)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
727 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
728 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
729 public boolean getMoreResults() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
730 return getMoreResults(CLOSE_ALL_RESULTS);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
731 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
732
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
733 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
734 * Moves to this Statement object's next result, deals with any current
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
735 * ResultSet object(s) according to the instructions specified by the given
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
736 * flag, and returns true if the next result is a ResultSet object.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
737 *
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
738 * There are no more results when the following is true:
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
739 * (!getMoreResults() &amp;&amp; (getUpdateCount() == -1)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
740 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
741 * @param current one of the following Statement constants indicating what
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
742 * should happen to current ResultSet objects obtained using
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
743 * the method getResultSet: CLOSE_CURRENT_RESULT,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
744 * KEEP_CURRENT_RESULT, or CLOSE_ALL_RESULTS
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
745 * @return true if the next result is a ResultSet object; false if it is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
746 * an update count or there are no more results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
747 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
748 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
749 @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
750 public boolean getMoreResults(final int current) throws SQLException {
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
751 // protect against people calling this on an uninitialized state
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
752 if (lastResponseList == null) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
753 header = null;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
754 return false;
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
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
757 if (current == CLOSE_CURRENT_RESULT) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
758 lastResponseList.closeCurrentResponse();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
759 } else if (current == CLOSE_ALL_RESULTS) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
760 lastResponseList.closeCurOldResponses();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
761 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
762 // we default to keep current result, which requires no action
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
763 header = lastResponseList.getNextResponse();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
764
260
d3d466182d65 Prevent NullPointerExceptions to be thrown when header == null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 259
diff changeset
765 return (header != null && header instanceof MonetConnection.ResultSetResponse);
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
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
768 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
769 * Retrieves the number of seconds the driver will wait for a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
770 * Statement object to execute. If the limit is exceeded, a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
771 * SQLException is thrown.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
772 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
773 * @return the current query timeout limit in seconds; zero means
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
774 * there is no limit
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
775 * @see #setQueryTimeout(int)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
776 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
777 @Override
249
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
778 public int getQueryTimeout() {
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
779 return queryTimeout;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
780 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
781
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
782 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
783 * Retrieves the current result as a ResultSet object. This method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
784 * should be called only once per result.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
785 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
786 * @return the current result as a ResultSet object or null if the result
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
787 * is an update count or there are no more results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
788 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
789 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
790 @Override
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
791 public ResultSet getResultSet() throws SQLException {
480
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
792 if (header != null && header instanceof MonetConnection.ResultSetResponse)
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
793 return new MonetResultSet(this, (MonetConnection.ResultSetResponse)header);
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
794 return null;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
795 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
796
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 * Retrieves the result set concurrency for ResultSet objects generated
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
799 * by this Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
800 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
801 * @return either ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
802 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
803 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
804 public int getResultSetConcurrency() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
805 return resultSetConcurrency;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
806 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
807
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
808 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
809 * Retrieves the result set holdability for ResultSet objects
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
810 * generated by this Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
811 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
812 * @return either ResultSet.HOLD_CURSORS_OVER_COMMIT or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
813 * ResultSet.CLOSE_CURSORS_AT_COMMIT
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
250
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
816 public int getResultSetHoldability() {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
817 return ResultSet.HOLD_CURSORS_OVER_COMMIT;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
818 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
819
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 * Retrieves the result set type for ResultSet objects generated by this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
822 * Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
823 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
824 * @return one of ResultSet.TYPE_FORWARD_ONLY,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
825 * ResultSet.TYPE_SCROLL_INSENSITIVE, or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
826 * ResultSet.TYPE_SCROLL_SENSITIVE
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
827 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
828 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
829 public int getResultSetType() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
830 return resultSetType;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
831 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
832
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
833 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
834 * Retrieves the current result as an update count; if the result is a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
835 * ResultSet object or there are no more results, -1 is returned. This
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
836 * method should be called only once per result.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
837 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
838 * @return the current result as an update count; -1 if the current result
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
839 * is a ResultSet object or there are no more results
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
840 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
841 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
842 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
843 public int getUpdateCount() throws SQLException {
378
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
844 long ret = getLargeUpdateCount();
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
845 if (ret >= Integer.MAX_VALUE)
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
846 return Integer.MAX_VALUE;
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
847 return (int)ret;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
848 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
849
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
850 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
851 * Retrieves the first warning reported by calls on this Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
852 * If there is more than one warning, subsequent warnings will be chained to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
853 * the first one and can be retrieved by calling the method
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
854 * SQLWarning.getNextWarning on the warning that was retrieved previously.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
855 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
856 * This method may not be called on a closed statement; doing so will cause
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
857 * an SQLException to be thrown.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
858 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
859 * Note: Subsequent warnings will be chained to this SQLWarning.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
860 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
861 * @return the first SQLWarning object or null if there are none
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
862 * @throws SQLException if a database access error occurs or this method is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
863 * called on a closed connection
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
864 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
865 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
866 public SQLWarning getWarnings() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
867 if (closed)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
868 throw new SQLException("Cannot call on closed Statement", "M1M20");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
869
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
870 // if there are no warnings, this will be null, which fits with the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
871 // specification.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
872 return warnings;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
873 }
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 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
876 * Sets the SQL cursor name to the given String, which will be used
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
877 * by subsequent Statement object execute methods. This name can
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
878 * then be used in SQL positioned update or delete statements to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
879 * identify the current row in the ResultSet object generated by
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
880 * this statement. If the database does not support positioned
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
881 * update/delete, this method is a noop. To insure that a cursor has
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
882 * the proper isolation level to support updates, the cursor's
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
883 * SELECT statement should have the form SELECT FOR UPDATE. If FOR
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
884 * UPDATE is not present, positioned updates may fail.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
885 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
886 * <b>Note:</b> By definition, the execution of positioned updates
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
887 * and deletes must be done by a different Statement object than the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
888 * one that generated the ResultSet object being used for
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
889 * positioning. Also, cursor names must be unique within a
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
890 * connection.
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
891 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
892 * Since MonetDB does not support positioned update/delete, this
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
893 * method is a noop.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
894 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
895 * @param name the new cursor name, which must be unique within a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
896 * connection
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
897 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
898 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
899 @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
900 public void setCursorName(final String name) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
901 addWarning("setCursorName: positioned updates/deletes not supported", "01M21");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
902 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
903
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
904 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
905 * Sets escape processing on or off. If escape scanning is on (the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
906 * default), the driver will do escape substitution before sending
710
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
907 * the SQL statement to the database.
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
908 * Note: Since prepared statements have usually been parsed prior to
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
909 * making this call, disabling escape processing for
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
910 * PreparedStatements objects will have no effect.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
911 *
710
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
912 * The MonetDB JDBC driver does not implement scanning and conditional
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
913 * removal of escape sequences. Newer MonetDB servers (post 11.45)
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
914 * have the capability to parse and handle JDBC/ODBC escape sequences
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
915 * but you can not disable it.
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
916 *
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
917 * @param enable true to enable escape processing; false to disable it
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
918 * @throws SQLException if a database access error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
919 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
920 @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
921 public void setEscapeProcessing(final boolean enable) throws SQLException {
710
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
922 // MonetDB releases Sep2022 (11.45) and older do not support JDBC escape processing in the server or driver
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
923 if ((connection.getDatabaseMajorVersion() == 11) && (connection.getDatabaseMinorVersion() <= 45)) {
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
924 if (enable)
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
925 addWarning("setEscapeProcessing(true): JDBC escape syntax is not supported by this driver or server", "01M22");
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
926 } else {
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
927 // For newer servers (post 11.45) it is not possible to turn it off
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
928 if (! enable)
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
929 addWarning("setEscapeProcessing(false): Cannot disable JDBC escape processing.", "M1M05");
437e51b4c169 Future versions of MonetDB (post Sep2022) will have capability to parse and execute ODBC/JDBC escape sequence syntax.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 709
diff changeset
930 }
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
931 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
932
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
933 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
934 * Gives the driver a hint as to the direction in which rows will be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
935 * processed in ResultSet objects created using this Statement object.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
936 * The default value is ResultSet.FETCH_FORWARD.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
937 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
938 * Note that this method sets the default fetch direction for result sets
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
939 * generated by this Statement object. Each result set has its own methods
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
940 * for getting and setting its own fetch direction.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
941 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
942 * @param direction the initial direction for processing rows
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
943 * @throws SQLException if a database access error occurs or the given
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
944 * direction is not one of ResultSet.FETCH_FORWARD,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
945 * ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
946 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
947 @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
948 public void setFetchDirection(final int direction) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
949 if (direction == ResultSet.FETCH_FORWARD ||
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
950 direction == ResultSet.FETCH_REVERSE ||
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
951 direction == ResultSet.FETCH_UNKNOWN)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
952 {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
953 fetchDirection = direction;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
954 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
955 throw new SQLException("Illegal direction: " + direction, "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
956 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
957 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
958
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
959 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
960 * Gives the JDBC driver a hint as to the number of rows that should be
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
961 * fetched from the database when more rows are needed. The number of rows
696
07d60185eeb9 Eliminate hardcoded value 250 in the constructor of MonetPreparedStatement. For this an internal package method MonetConnection.getDefaultFetchSize() is added.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 692
diff changeset
962 * specified affects only ResultSet created using this Statement. If the
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
963 * value specified is zero, then the hint is ignored.
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 * @param rows the number of rows to fetch
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
966 * @throws SQLException if the condition 0 &lt;= rows &lt;= this.getMaxRows()
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
967 * is not satisfied.
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 @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
970 public void setFetchSize(final int rows) throws SQLException {
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
971 if (rows >= 0 && !(maxRows != 0 && rows > getMaxRows())) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
972 fetchSize = rows;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
973 } else {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
974 throw new SQLException("Illegal fetch size value: " + rows, "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
975 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
976 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
977
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
978 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
979 * Sets the limit for the maximum number of bytes in a ResultSet
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
980 * column storing character or binary values to the given number of
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
981 * bytes. This limit applies only to BINARY, VARBINARY,
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
982 * LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. If the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
983 * limit is exceeded, the excess data is silently discarded. For
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
984 * maximum portability, use values greater than 256.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
985 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
986 * MonetDB does not support any fieldsize limiting, and hence the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
987 * driver does not emulate it either, since it doesn't really lead
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
988 * to memory reduction.
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 * @param max the new column size limit in bytes; zero means there
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
991 * is no limit
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
992 * @throws SQLException if a database access error occurs or the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
993 * condition max &gt;= 0 is not satisfied
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
994 * @see #getMaxFieldSize()
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
995 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
996 @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
997 public void setMaxFieldSize(final int max) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
998 if (max < 0)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
999 throw new SQLException("Illegal max value: " + max, "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1000 if (max > 0)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1001 addWarning("setMaxFieldSize: field size limitation not supported", "01M23");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1002 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1003
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 * Sets the limit for the maximum number of rows that any ResultSet object
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1006 * can contain to the given number. If the limit is exceeded, the excess
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1007 * rows are silently dropped.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1008 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1009 * @param max the new max rows limit; zero means there is no limit
194
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
1010 * @throws SQLException if the condition max &gt;= 0 is not satisfied
1296dbcc4958 Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 183
diff changeset
1011 * @see #getMaxRows()
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1012 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1013 @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
1014 public void setMaxRows(final int max) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1015 if (max < 0)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1016 throw new SQLException("Illegal max value: " + max, "M1M05");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1017 maxRows = max;
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 number of seconds the driver will wait for a Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1022 * object to execute to the given number of seconds. If the limit is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1023 * exceeded, an SQLException is thrown.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1024 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1025 * @param seconds the new query timeout limit in seconds; zero means
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1026 * there is no limit
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1027 * @throws SQLException if a database access error occurs or the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1028 * condition seconds &gt;= 0 is not satisfied
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1029 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1030 @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
1031 public void setQueryTimeout(final int seconds) throws SQLException {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1032 if (seconds < 0)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1033 throw new SQLException("Illegal timeout value: " + seconds, "M1M05");
249
46385d8ff8c9 Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 200
diff changeset
1034 queryTimeout = seconds;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1035 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1036
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1037 //== 1.6 methods (JDBC 4.0)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1038
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1039 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1040 * Retrieves whether this Statement object has been closed. A
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1041 * Statement is closed if the method close has been called on it, or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1042 * if it is automatically closed.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1043 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1044 * @return true if this Statement object is closed; false if it is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1045 * still open
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 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1048 public boolean isClosed() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1049 return closed;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1050 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1051
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1052 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1053 * Requests that a Statement be pooled or not pooled. The value
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1054 * specified is a hint to the statement pool implementation
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
1055 * indicating whether the application wants the statement to be
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1056 * pooled. It is up to the statement pool manager as to whether the
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1057 * hint is used.
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1058 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1059 * The poolable value of a statement is applicable to both internal
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1060 * statement caches implemented by the driver and external statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1061 * caches implemented by application servers and other applications.
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1062 *
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1063 * By default, a Statement is not poolable when created, and a
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1064 * PreparedStatement and CallableStatement are poolable when
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1065 * created.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1066 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1067 * @param poolable requests that the statement be pooled if true
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1068 * and that the statement not be pooled if false
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1069 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1070 @Override
295
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1071 public void setPoolable(final boolean poolable) {
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1072 this.poolable = poolable;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1073 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1074
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1075 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1076 * Returns a value indicating whether the Statement is poolable or
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1077 * not.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1078 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1079 * @return true if the Statement is poolable; false otherwise
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1080 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1081 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1082 public boolean isPoolable() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1083 return poolable;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1084 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1085
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1086 //== 1.7 methods (JDBC 4.1)
29
c26213e86442 Use newSQLFeatureNotSupportedException() for setArray()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 14
diff changeset
1087
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1088 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1089 * Specifies that this Statement will be closed when all its
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1090 * dependent result sets are closed. If execution of the Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1091 * does not produce any result sets, this method has no effect.
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 * @throws SQLException if this method is called on a closed Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1094 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1095 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1096 public void closeOnCompletion() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1097 if (closed)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1098 throw new SQLException("Cannot call on closed Statement", "M1M20");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1099 closeOnCompletion = true;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1100 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1101
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1102 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1103 * Returns a value indicating whether this Statement will be closed
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1104 * when all its dependent result sets are closed.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1105 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1106 * @return true if the Statement will be closed when all of its
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1107 * dependent result sets are closed; false otherwise
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1108 * @throws SQLException if this method is called on a closed Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1109 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1110 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1111 public boolean isCloseOnCompletion() throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1112 if (closed)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1113 throw new SQLException("Cannot call on closed Statement", "M1M20");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1114 return closeOnCompletion;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1115 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1116
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: 361
diff changeset
1117 //== 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: 361
diff changeset
1118
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: 361
diff changeset
1119 /**
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: 361
diff changeset
1120 * Retrieves the current result as an update count;
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: 361
diff changeset
1121 * if the result is a ResultSet object or there are no more results, -1 is returned.
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: 361
diff changeset
1122 * This method should be called only once per result.
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: 361
diff changeset
1123 *
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: 361
diff changeset
1124 * 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: 361
diff changeset
1125 * 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: 361
diff changeset
1126 *
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: 361
diff changeset
1127 * @return the current result as an update count; -1 if the current
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: 361
diff changeset
1128 * result is a ResultSet object or there are no more results
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: 361
diff changeset
1129 * @throws SQLException if a database access error occurs or this
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: 361
diff changeset
1130 * method is called on a closed 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: 361
diff changeset
1131 */
480
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
1132 @Override
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: 361
diff changeset
1133 public long getLargeUpdateCount() throws SQLException {
378
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1134 if (header != null) {
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1135 if (header instanceof MonetConnection.UpdateResponse) {
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1136 final long updCnt = ((MonetConnection.UpdateResponse)header).count;
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1137 if (updCnt >= 0)
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1138 return updCnt;
378
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1139 }
02f353f62abe Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 377
diff changeset
1140 }
480
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
1141 return -1;
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: 361
diff changeset
1142 }
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: 361
diff changeset
1143
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: 361
diff changeset
1144 /**
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: 361
diff changeset
1145 * Sets the limit for the maximum number of rows that any 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: 361
diff changeset
1146 * generated by this Statement object can contain to the given number.
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: 361
diff changeset
1147 * If the limit is exceeded, the excess rows are silently dropped.
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: 361
diff changeset
1148 *
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: 361
diff changeset
1149 * This method should be used when the row limit 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: 361
diff changeset
1150 * 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: 361
diff changeset
1151 *
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: 361
diff changeset
1152 * @param max the new max rows limit; zero means there is no limit
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: 361
diff changeset
1153 * @throws SQLException if a database access error occurs,
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: 361
diff changeset
1154 * this method is called on a closed Statement or
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: 361
diff changeset
1155 * the condition max &gt;= 0 is not satisfied
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: 361
diff changeset
1156 * @see #getLargeMaxRows()
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: 361
diff changeset
1157 */
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: 361
diff changeset
1158 @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: 361
diff changeset
1159 public void setLargeMaxRows(final long max) 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: 361
diff changeset
1160 if (max < 0)
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: 361
diff changeset
1161 throw new SQLException("Illegal max value: " + max, "M1M05");
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: 361
diff changeset
1162 maxRows = max;
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: 361
diff changeset
1163 }
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: 361
diff changeset
1164
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: 361
diff changeset
1165 /**
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: 361
diff changeset
1166 * Retrieves the maximum number of rows that a ResultSet object produced by
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: 361
diff changeset
1167 * this Statement object can contain. If this limit is exceeded, the excess
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: 361
diff changeset
1168 * rows are silently dropped.
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: 361
diff changeset
1169 *
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: 361
diff changeset
1170 * This method should be used when the returned row limit 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: 361
diff changeset
1171 * The default implementation will return 0
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: 361
diff changeset
1172 *
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: 361
diff changeset
1173 * @return the current maximum number of rows for 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: 361
diff changeset
1174 * produced by this Statement object; zero means there is no limit
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: 361
diff changeset
1175 * @see #setLargeMaxRows(long max)
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: 361
diff changeset
1176 */
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: 361
diff changeset
1177 @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: 361
diff changeset
1178 public long getLargeMaxRows() {
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: 361
diff changeset
1179 return maxRows;
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: 361
diff changeset
1180 }
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: 361
diff changeset
1181
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: 361
diff changeset
1182 /**
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: 361
diff changeset
1183 * Submits a batch of commands to the database for execution and if
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: 361
diff changeset
1184 * all commands execute successfully, returns an array of update counts.
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: 361
diff changeset
1185 * The long elements of the array that is returned are ordered to
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: 361
diff changeset
1186 * correspond to the commands in the batch, which are ordered according
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: 361
diff changeset
1187 * to the order in which they were added to the batch.
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: 361
diff changeset
1188 * The elements in the array returned by the method executeLargeBatch
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: 361
diff changeset
1189 * may be one of the following:
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: 361
diff changeset
1190 * <ol>
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: 361
diff changeset
1191 * <li>A number greater than or equal to zero -- indicates that the command
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: 361
diff changeset
1192 * was processed successfully and is an update count giving the number of
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1193 * rows in the database that were affected by the command's execution
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: 361
diff changeset
1194 * <li>A value of SUCCESS_NO_INFO -- indicates that the command was
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1195 * processed successfully but that the number of rows affected is unknown
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1196 * <p>If one of the commands in a batch update fails to execute properly,
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: 361
diff changeset
1197 * this method throws a BatchUpdateException, and a JDBC driver may or
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: 361
diff changeset
1198 * may not continue to process the remaining commands in the batch.
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: 361
diff changeset
1199 * However, the driver's behavior must be consistent with a particular DBMS,
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: 361
diff changeset
1200 * either always continuing to process commands or never continuing to process
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: 361
diff changeset
1201 * commands. If the driver continues processing after a failure, the array
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: 361
diff changeset
1202 * returned by the method BatchUpdateException.getLargeUpdateCounts will
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: 361
diff changeset
1203 * contain as many elements as there are commands in the batch, and at
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1204 * least one of the elements will be the following:</p>
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: 361
diff changeset
1205 * <li>A value of EXECUTE_FAILED -- indicates that the command failed to
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: 361
diff changeset
1206 * execute successfully and occurs only if a driver continues to process
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1207 * commands after a command fails
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: 361
diff changeset
1208 * </ol>
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: 361
diff changeset
1209 *
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: 361
diff changeset
1210 * 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: 361
diff changeset
1211 * 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: 361
diff changeset
1212 *
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: 361
diff changeset
1213 * MonetDB does continues after an error has occurred in the batch.
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: 361
diff changeset
1214 * If one of the commands attempts to return a result set, an
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: 361
diff changeset
1215 * SQLException is added to the SQLException list and thrown
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: 361
diff changeset
1216 * afterwards execution. Failing queries result in SQLExceptions
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: 361
diff changeset
1217 * too and may cause subparts of the batch to fail as well.
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: 361
diff changeset
1218 *
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: 361
diff changeset
1219 * @return an array of update counts containing one element for each
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: 361
diff changeset
1220 * command in the batch. The elements of the array are ordered
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: 361
diff changeset
1221 * according to the order in which commands were added to the batch.
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: 361
diff changeset
1222 * @throws SQLException if a database access error occurs, this method is called
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: 361
diff changeset
1223 * on a closed Statement or the driver does not support batch statements.
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1224 * @throws BatchUpdateException (a subclass of SQLException) if one of the
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1225 * commands sent to the database fails to execute properly or
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1226 * attempts to return a result set.
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: 361
diff changeset
1227 */
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: 361
diff changeset
1228 @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: 361
diff changeset
1229 public long[] executeLargeBatch() 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: 361
diff changeset
1230 if (batch == null || batch.isEmpty()) {
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: 361
diff changeset
1231 return new long[0];
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: 361
diff changeset
1232 }
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: 361
diff changeset
1233
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1234 // this method is synchronized/locked to make sure no one gets in between the
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1235 // operations we execute below
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1236 if (batchLock == null) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1237 // create a ReentrantLock at first time use
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1238 batchLock = new ReentrantLock();
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: 361
diff changeset
1239 }
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1240 batchLock.lock();
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1241 try {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1242 final long[] counts = new long[batch.size()];
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1243 final String sep = connection.queryTempl[2];
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1244 final int sepLen = sep.length();
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1245 final BatchUpdateException e = new BatchUpdateException(
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1246 "Error(s) occurred while executing the batch, " +
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1247 "see chained SQLExceptions for details", "22000", 22000, counts, null);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1248 final StringBuilder tmpBatch = new StringBuilder(MapiSocket.BLOCK);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1249 int offset = 0;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1250 boolean first = true;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1251 boolean error = false;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1252
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1253 for (int i = 0; i < batch.size(); i++) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1254 String tmp = batch.get(i);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1255 if (sepLen + tmp.length() > MapiSocket.BLOCK) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1256 // The thing is too big. Way too big. Since it won't
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1257 // be optimal anyway, just add it to whatever we have
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1258 // and continue.
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1259 if (!first)
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1260 tmpBatch.append(sep);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1261 tmpBatch.append(tmp);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1262 // send and receive
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1263 error |= internalBatch(tmpBatch, counts, offset, i + 1, e);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1264 offset = i;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1265 tmpBatch.setLength(0); // clear the buffer
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1266 first = true;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1267 continue;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1268 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1269 if (tmpBatch.length() + sepLen + tmp.length() >= MapiSocket.BLOCK) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1270 // send and receive
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1271 error |= internalBatch(tmpBatch, counts, offset, i + 1, e);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1272 offset = i;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1273 tmpBatch.setLength(0); // clear the buffer
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1274 first = true;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1275 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1276 if (first)
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1277 first = false;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1278 else
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1279 tmpBatch.append(sep);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1280 tmpBatch.append(tmp);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1281 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1282 // send and receive
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1283 error |= internalBatch(tmpBatch, counts, offset, counts.length, e);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1284
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1285 // throw BatchUpdateException if it contains something
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1286 if (error)
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1287 throw e;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1288
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1289 // otherwise just return the counts
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1290 return counts;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1291 } finally {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1292 batch.clear();
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1293 batchLock.unlock();
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1294 }
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: 361
diff changeset
1295 }
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: 361
diff changeset
1296
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1297 private boolean internalBatch(
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1298 final StringBuilder batch,
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1299 final long[] counts,
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1300 int offset,
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1301 final int max,
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1302 final BatchUpdateException e)
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1303 throws BatchUpdateException
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1304 {
692
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
1305 if (batch.length() == 0)
2233b172e06d Add checks for sql String parameter to prevent NullPointerException or executing an empty sql String.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 625
diff changeset
1306 return false;
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1307 try {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1308 long count = -1;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1309 boolean hasResultSet = internalExecute(batch.toString());
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1310
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1311 if (!hasResultSet)
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1312 count = getLargeUpdateCount();
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1313
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1314 do {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1315 if (offset >= max)
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1316 throw new SQLException("Overflow: don't use multi statements when batching (" + max + ")", "M1M16");
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1317 if (hasResultSet) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1318 e.setNextException(
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1319 new SQLException("Batch query produced a ResultSet! " +
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1320 "Ignoring and setting update count to value " + EXECUTE_FAILED, "M1M17"));
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1321 counts[offset] = EXECUTE_FAILED;
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1322 } else {
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1323 counts[offset] = (count >= 0) ? count : SUCCESS_NO_INFO;
392
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1324 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1325 offset++;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1326 } while ((hasResultSet = getMoreResults()) || (count = getLargeUpdateCount()) != -1);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1327 } catch (SQLException ex) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1328 e.setNextException(ex);
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1329 for (; offset < max; offset++) {
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1330 counts[offset] = EXECUTE_FAILED;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1331 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1332 return true;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1333 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1334 return false;
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1335 }
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1336
00c6bb1d84ed Improve executeLargeBatch(). Make sure it calls getLargeUpdateCount() instead of getUpdateCount() to populate the long[] elements.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 391
diff changeset
1337
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: 361
diff changeset
1338 /**
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: 361
diff changeset
1339 * Executes the given SQL statement, which may be an INSERT, UPDATE, or
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: 361
diff changeset
1340 * DELETE statement or an SQL statement that returns nothing, such as an
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: 361
diff changeset
1341 * SQL 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: 361
diff changeset
1342 *
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: 361
diff changeset
1343 * 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: 361
diff changeset
1344 * Note: This method cannot be called on a PreparedStatement or CallableStatement.
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: 361
diff changeset
1345 * The default implementation will throw SQLFeatureNotSupportedException
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: 361
diff changeset
1346 *
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: 361
diff changeset
1347 * @param sql an SQL Data Manipulation Language (DML) statement, such as
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: 361
diff changeset
1348 * INSERT, UPDATE or DELETE; or an SQL statement that returns 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: 361
diff changeset
1349 * 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: 361
diff changeset
1350 * @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: 361
diff changeset
1351 * 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: 361
diff changeset
1352 * @throws SQLException if a database access error occurs, this method is
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: 361
diff changeset
1353 * called on a closed Statement, the given SQL statement produces a
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: 361
diff changeset
1354 * ResultSet object, the method is called on a PreparedStatement or CallableStatement
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: 361
diff changeset
1355 */
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: 361
diff changeset
1356 @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: 361
diff changeset
1357 public long executeLargeUpdate(final String sql) 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: 361
diff changeset
1358 if (execute(sql) != false)
625
b32999570f4d executeUpdate(sql) and executeLargeUpdate(sql) expect a Statement, not a Query. Improved the text of the Exception msg.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
1359 throw new SQLException("Statement produced a result set", "M1M17");
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: 361
diff changeset
1360
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1361 return Math.max(getLargeUpdateCount(), 0L);
376
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 361
diff changeset
1362 }
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: 361
diff changeset
1363
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: 361
diff changeset
1364 /**
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: 361
diff changeset
1365 * Executes the given SQL statement and signals the driver with the
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: 361
diff changeset
1366 * given flag about whether the auto-generated keys produced by this
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: 361
diff changeset
1367 * Statement object should be made available for retrieval.
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: 361
diff changeset
1368 * The driver will ignore the flag if the SQL statement is not an INSERT
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: 361
diff changeset
1369 * statement, or an SQL statement able to return auto-generated keys
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: 361
diff changeset
1370 * (the list of such statements is vendor-specific).
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: 361
diff changeset
1371 *
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: 361
diff changeset
1372 * 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: 361
diff changeset
1373 * Note: This method cannot be called on a PreparedStatement or CallableStatement.
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: 361
diff changeset
1374 * The default implementation will throw SQLFeatureNotSupportedException
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: 361
diff changeset
1375 *
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: 361
diff changeset
1376 * @param sql an SQL Data Manipulation Language (DML) statement, such as
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: 361
diff changeset
1377 * INSERT, UPDATE or DELETE; or an SQL statement that returns 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: 361
diff changeset
1378 * 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: 361
diff changeset
1379 * @param autoGeneratedKeys - a flag indicating whether
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: 361
diff changeset
1380 * auto-generated keys should be made available for
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: 361
diff changeset
1381 * retrieval; one of the following constants:
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: 361
diff changeset
1382 * Statement.RETURN_GENERATED_KEYS
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: 361
diff changeset
1383 * Statement.NO_GENERATED_KEYS
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: 361
diff changeset
1384 * @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: 361
diff changeset
1385 * 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: 361
diff changeset
1386 * @throws SQLException if a database access error occurs, this method is
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: 361
diff changeset
1387 * called on a closed Statement, the given SQL statement produces a
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: 361
diff changeset
1388 * ResultSet object, the given constant is not one of those allowed,
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: 361
diff changeset
1389 * the method is called on a PreparedStatement or CallableStatement
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: 361
diff changeset
1390 */
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: 361
diff changeset
1391 @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: 361
diff changeset
1392 public long executeLargeUpdate(final String sql, final int autoGeneratedKeys)
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: 361
diff changeset
1393 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: 361
diff changeset
1394 {
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: 361
diff changeset
1395 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS &&
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: 361
diff changeset
1396 autoGeneratedKeys != Statement.NO_GENERATED_KEYS)
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: 361
diff changeset
1397 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05");
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: 361
diff changeset
1398
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: 361
diff changeset
1399 /* MonetDB has no way to disable this, so just do the normal thing ;) */
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: 361
diff changeset
1400 if (execute(sql) != false)
625
b32999570f4d executeUpdate(sql) and executeLargeUpdate(sql) expect a Statement, not a Query. Improved the text of the Exception msg.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 623
diff changeset
1401 throw new SQLException("Statement produced a result set", "M1M17");
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: 361
diff changeset
1402
967
5cc071c5c170 Corrected the returned integer values of Statement methods executeUpdate(...), executeLargeUpdate(...), getUpdateCount() and getLargeUpdateCount() and PreparedStatement methods executeUpdate() and executeLargeUpdate(). They returned -2 for DDL statements, which was not in compliance with the JDBC API documentation.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 943
diff changeset
1403 return Math.max(getLargeUpdateCount(), 0L);
376
ffdc7b0e102d Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 361
diff changeset
1404 }
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: 361
diff changeset
1405
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: 361
diff changeset
1406 /**
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: 361
diff changeset
1407 * Executes the given SQL statement and signals the driver that the
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: 361
diff changeset
1408 * auto-generated keys indicated in the given array should be made
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: 361
diff changeset
1409 * available for retrieval. The driver will ignore the array if the
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: 361
diff changeset
1410 * SQL statement is not an INSERT 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: 361
diff changeset
1411 *
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: 361
diff changeset
1412 * 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: 361
diff changeset
1413 * Note: This method cannot be called on a PreparedStatement or CallableStatement.
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: 361
diff changeset
1414 * The default implementation will throw SQLFeatureNotSupportedException
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: 361
diff changeset
1415 *
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
1416 * MonetDB only supports returning the generated key for one column,
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: 361
diff changeset
1417 * which will be the first column that has a serial. Hence, this
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: 361
diff changeset
1418 * method cannot work as required and the driver will fall back to
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: 361
diff changeset
1419 * executing with request to the database to return the generated
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: 361
diff changeset
1420 * key, if any.
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: 361
diff changeset
1421 *
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: 361
diff changeset
1422 * @param sql an SQL Data Manipulation Language (DML) statement, such as
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: 361
diff changeset
1423 * INSERT, UPDATE or DELETE; or an SQL statement that returns 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: 361
diff changeset
1424 * 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: 361
diff changeset
1425 * @param columnIndexes an array of column indexes indicating the
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: 361
diff changeset
1426 * columns that should be returned from the inserted row
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: 361
diff changeset
1427 * @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: 361
diff changeset
1428 * 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: 361
diff changeset
1429 * @throws SQLException if a database access error occurs, this method is
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: 361
diff changeset
1430 * called on a closed Statement, the given SQL statement produces a
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: 361
diff changeset
1431 * ResultSet object, the second argument supplied to this method is
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: 361
diff changeset
1432 * not an int array whose elements are valid column indexes,
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: 361
diff changeset
1433 * the method is called on a PreparedStatement or CallableStatement
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: 361
diff changeset
1434 */
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: 361
diff changeset
1435 @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: 361
diff changeset
1436 public long executeLargeUpdate(final String sql, final int[] columnIndexes)
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: 361
diff changeset
1437 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: 361
diff changeset
1438 {
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: 361
diff changeset
1439 addWarning("executeLargeUpdate: generated keys for fixed set of columns not supported", "01M18");
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: 361
diff changeset
1440 return executeLargeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
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: 361
diff changeset
1441 }
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: 361
diff changeset
1442
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: 361
diff changeset
1443 /**
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: 361
diff changeset
1444 * Executes the given SQL statement and signals the driver that the
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: 361
diff changeset
1445 * auto-generated keys indicated in the given array should be made
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: 361
diff changeset
1446 * available for retrieval. The driver will ignore the array if the
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: 361
diff changeset
1447 * SQL statement is not an INSERT 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: 361
diff changeset
1448 *
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: 361
diff changeset
1449 * 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: 361
diff changeset
1450 * Note: This method cannot be called on a PreparedStatement or CallableStatement.
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: 361
diff changeset
1451 * The default implementation will throw SQLFeatureNotSupportedException
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: 361
diff changeset
1452 *
943
ff075ed5ce81 Spell check.
Sjoerd Mullender <sjoerd@acm.org>
parents: 937
diff changeset
1453 * MonetDB only supports returning the generated key for one column,
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: 361
diff changeset
1454 * which will be the first column that has a serial. Hence, this
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: 361
diff changeset
1455 * method cannot work as required and the driver will fall back to
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: 361
diff changeset
1456 * executing with request to the database to return the generated
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: 361
diff changeset
1457 * key, if any.
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: 361
diff changeset
1458 *
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: 361
diff changeset
1459 * @param sql an SQL Data Manipulation Language (DML) statement, such as
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: 361
diff changeset
1460 * INSERT, UPDATE or DELETE; or an SQL statement that returns 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: 361
diff changeset
1461 * 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: 361
diff changeset
1462 * @param columnNames an array of the names of the columns that
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: 361
diff changeset
1463 * should be returned from the inserted row
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: 361
diff changeset
1464 * @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: 361
diff changeset
1465 * 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: 361
diff changeset
1466 * @throws SQLException if a database access error occurs, this method is
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: 361
diff changeset
1467 * called on a closed Statement, the given SQL statement produces a
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: 361
diff changeset
1468 * ResultSet object, the second argument supplied to this method is
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: 361
diff changeset
1469 * not a String array whose elements are valid column names,
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: 361
diff changeset
1470 * the method is called on a PreparedStatement or CallableStatement
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: 361
diff changeset
1471 */
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: 361
diff changeset
1472 @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: 361
diff changeset
1473 public long executeLargeUpdate(final String sql, final String[] columnNames)
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: 361
diff changeset
1474 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: 361
diff changeset
1475 {
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: 361
diff changeset
1476 addWarning("executeLargeUpdate: generated keys for fixed set of columns not supported", "01M18");
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: 361
diff changeset
1477 return executeLargeUpdate(sql, Statement.RETURN_GENERATED_KEYS);
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: 361
diff changeset
1478 }
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: 361
diff changeset
1479
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1480 //== end methods of interface Statement
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1481
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: 361
diff changeset
1482
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: 361
diff changeset
1483 //== 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: 361
diff changeset
1484
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1485 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1486 * Adds a warning to the pile of warnings this Statement object has. If
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1487 * there were no warnings (or clearWarnings was called) this warning will
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1488 * be the first, otherwise this warning will get appended to the current
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1489 * warning.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1490 * @param reason the warning message
709
bdeabbd46ec6 Resolve javac and javadoc warnings when compiled with JDK19.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 696
diff changeset
1491 * @param sqlstate the SQLState code (5 characters)
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1492 */
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
1493 private void addWarning(final String reason, final String sqlstate) {
183
57f09396b22c Small improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 181
diff changeset
1494 SQLWarning warng = new SQLWarning(reason, sqlstate);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1495 if (warnings == null) {
183
57f09396b22c Small improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 181
diff changeset
1496 warnings = warng;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1497 } else {
183
57f09396b22c Small improvements
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 181
diff changeset
1498 warnings.setNextWarning(warng);
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1499 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1500 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1501
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 * Closes this Statement if there are no more open ResultSets
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1504 * (Responses). Called by MonetResultSet.close().
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1505 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1506 void closeIfCompletion() {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1507 if (!closeOnCompletion || lastResponseList == null)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1508 return;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1509 if (!lastResponseList.hasUnclosedResponses())
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1510 close();
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1511 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1512 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1513
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1514 /**
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1515 * This internal subclass is not intended for normal use. Therefore it is restricted to
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1516 * classes from the very same package only.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1517 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1518 * Known issues with this class: some methods of the ResultSetMetaData object (obtained via getMetaData())
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1519 * require that its statement argument (accessed via getStatement()) has a valid Statement object set.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1520 * Instances of this subclass do not have a valid Statement (see special constructor), so
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1521 * those metadata methods do not return the correct values.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1522 * Special checks are programmed to prevent NullPointerExceptions, see above.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1523 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1524 * As of Jun2016 this class is only used by MonetStatement.getGeneratedKeys()
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1525 * Note: to resolve a javac -Xlint warning, this class definition is moved to this file.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1526 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1527 * TODO: try to eliminate the need for this class completely.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1528 */
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1529 final class MonetVirtualResultSet extends MonetResultSet {
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
1530 private String results[][];
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1531 private boolean closed;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1532
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1533 MonetVirtualResultSet(
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
1534 final Statement statement,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1535 final String[] columns,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1536 final String[] types,
003ae6d881db Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 292
diff changeset
1537 final String[][] results
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1538 ) throws IllegalArgumentException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1539 super(statement, columns, types, results.length);
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1540 this.results = results;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1541 closed = false;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1542 }
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 * This method is overridden in order to let it use the results array
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1546 * instead of the cache in the Statement object that created it.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1547 *
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1548 * @param row the number of the row to which the cursor should move. A
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1549 * positive number indicates the row number counting from the
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1550 * beginning of the result set; a negative number indicates the row
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1551 * number counting from the end of the result set
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1552 * @return true if the cursor is on the result set; false otherwise
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1553 * @throws SQLException if a database error occurs
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1554 */
13
749e3cf8b2aa Expanded the classes needed for import.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 0
diff changeset
1555 @Override
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1556 public boolean absolute(int row) throws SQLException {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1557 if (closed)
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1558 throw new SQLException("ResultSet is closed!", "M1M20");
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1559
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1560 // first calculate what the JDBC row is
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1561 if (row < 0) {
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1562 // calculate the negatives...
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
1563 row = (int) tupleCount + row + 1;
0
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 // now place the row not farther than just before or after the result
250
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
1566 if (row < 0)
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
1567 row = 0; // before first
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
1568 else if (row > tupleCount + 1)
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
1569 row = (int) tupleCount + 1; // after last
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1570
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1571 // store it
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1572 curRow = row;
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 // see if we have the row
250
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
1575 if (row < 1 || row > tupleCount)
3038e60bdca1 If methods never throw an SQLException, remove the "throws SQLException" part.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 249
diff changeset
1576 return false;
0
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1577
819
726a1d7b168c correct indentation
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 817
diff changeset
1578 System.arraycopy(results[row - 1], 0, tlp.values, 0, results[row - 1].length);
0
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 return true;
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1581 }
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1582
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 * Mainly here to prevent errors when the close method is called. There
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1585 * is no real need for this object to close it. We simply remove our
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1586 * resultset data.
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1587 */
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1588 @Override
a5a898f6886c Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff changeset
1589 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
1590 results = null;
480
849af4b76b28 Optimise code by reducing local variables which are used only once, replacing complex string concatenation by using StringBuilder, replacing some ternairy operators.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents: 451
diff changeset
1591 closed = true;
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
1592 super.close();
0
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 }