1
/* Copyright (c) 2001-2005, The HSQL Development Group
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
14
* Neither the name of the HSQL Development Group nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
22
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
/* Copyright (c) 2001-2005, The HSQL Development Group
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
14
* Neither the name of the HSQL Development Group nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,
22
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
32
package org.hsqldb.jdbc;
34
34
import java.io.IOException;
121
122
* preference to a jdbcStatement object, if a short-running SQL statement is
122
123
* to be executed more than a small number of times. <p>
124
* Please note, however, that 1.7.2 does not yet provide a sophisticated
125
* internal statement pooling facility. For this reason, the observation
126
* above is guaranteed to apply only under certain use patterns. <p>
128
* Specifically, when it can be otherwise avoided, it is to be considered poor
125
* When it can be otherwise avoided, it is to be considered poor
129
126
* practice to fully prepare (construct), parameterize, execute, fetch and
130
127
* close a jdbcPreparedStatement object for each execution cycle. Indeed, under
131
* HSQLDB 1.7.2, this practice is likely to be noticably <em>less</em>
128
* HSQLDB 1.8.0, this practice is likely to be noticably <em>less</em>
132
129
* performant for short-running statements than the equivalent process using
133
130
* jdbcStatement objects, albeit far more convenient, less error prone and
134
131
* certainly much less resource-intensive, especially when large binary and
1023
1028
* @exception SQLException if a database access error occurs
1025
1030
public void clearParameters() throws SQLException {
1027
1033
ArrayUtil.fillArray(parameterValues, null);
1034
ArrayUtil.clearArray(ArrayUtil.CLASS_CODE_BOOLEAN, parameterSet, 0,
1035
parameterSet.length);
1037
if (parameterStream != null) {
1038
ArrayUtil.clearArray(ArrayUtil.CLASS_CODE_BOOLEAN,
1039
parameterStream, 0, parameterStream.length);
1030
1043
//----------------------------------------------------------------------
1963
* Called just before execution or adding to batch, this ensures all the
1964
* parameters have been set.<p>
1966
* If a parameter has been set using a stream method, it should be set
1967
* again for the next reuse. When set using other methods, the parameter
1968
* setting is retained for the next use.
1970
private void checkParametersSet() throws SQLException {
1975
// do not check for compatibility with 1.8.0.x
1976
private void checkParametersSet() throws SQLException {
1978
if (parameterStream == null) {
1979
for (int i = 0; i < parameterSet.length; i++) {
1980
if (!parameterSet[i]) {
1981
throw Util.sqlException(Trace.JDBC_PARAMETER_NOT_SET);
1985
for (int i = 0; i < parameterSet.length; i++) {
1986
if (!parameterSet[i] &&!parameterStream[i]) {
1987
throw Util.sqlException(Trace.JDBC_PARAMETER_NOT_SET);
1991
ArrayUtil.clearArray(ArrayUtil.CLASS_CODE_BOOLEAN,
1992
parameterStream, 0, parameterStream.length);
1935
1998
* The internal parameter value setter always converts the parameter to
1936
1999
* the Java type required for data transmission. Target BINARY and OTHER
1937
2000
* types are converted directly. All other target types are converted