"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hsqldb/src/org/hsqldb/jdbc/JDBCPreparedStatement.java" between
hsqldb-2.7.1.zip and hsqldb-2.7.2.zip

About: HSQLDB (HyperSQL DataBase) is a SQL relational database engine written in Java. It supports nearly full ANSI-92 SQL (BNF format) and full core SQL:2008.

JDBCPreparedStatement.java  (hsqldb-2.7.1):JDBCPreparedStatement.java  (hsqldb-2.7.2)
/* Copyright (c) 2001-2022, The HSQL Development Group /* Copyright (c) 2001-2023, The HSQL Development Group
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* Redistributions of source code must retain the above copyright notice, this * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* Redistributions in binary form must reproduce the above copyright notice, * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
skipping to change at line 67 skipping to change at line 67
import java.sql.SQLWarning; import java.sql.SQLWarning;
import java.sql.SQLXML; import java.sql.SQLXML;
import java.sql.Time; import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet; import java.util.BitSet;
import java.util.Calendar; import java.util.Calendar;
import java.util.UUID; import java.util.UUID;
import org.hsqldb.HsqlDateTime;
import org.hsqldb.HsqlException; import org.hsqldb.HsqlException;
import org.hsqldb.SchemaObject; import org.hsqldb.SchemaObject;
import org.hsqldb.SessionInterface; import org.hsqldb.SessionInterface;
import org.hsqldb.StatementTypes; import org.hsqldb.StatementTypes;
import org.hsqldb.error.ErrorCode; import org.hsqldb.error.ErrorCode;
import org.hsqldb.lib.CharArrayWriter; import org.hsqldb.lib.CharArrayWriter;
import org.hsqldb.lib.CountdownInputStream; import org.hsqldb.lib.CountdownInputStream;
import org.hsqldb.lib.HsqlByteArrayOutputStream; import org.hsqldb.lib.HsqlByteArrayOutputStream;
import org.hsqldb.lib.StringConverter; import org.hsqldb.lib.StringConverter;
import org.hsqldb.navigator.RowSetNavigator; import org.hsqldb.navigator.RowSetNavigator;
skipping to change at line 92 skipping to change at line 91
import org.hsqldb.result.ResultProperties; import org.hsqldb.result.ResultProperties;
import org.hsqldb.types.BinaryData; import org.hsqldb.types.BinaryData;
import org.hsqldb.types.BinaryUUIDType; import org.hsqldb.types.BinaryUUIDType;
import org.hsqldb.types.BlobDataID; import org.hsqldb.types.BlobDataID;
import org.hsqldb.types.BlobInputStream; import org.hsqldb.types.BlobInputStream;
import org.hsqldb.types.ClobDataID; import org.hsqldb.types.ClobDataID;
import org.hsqldb.types.ClobInputStream; import org.hsqldb.types.ClobInputStream;
import org.hsqldb.types.DateTimeType; import org.hsqldb.types.DateTimeType;
import org.hsqldb.types.JavaObjectData; import org.hsqldb.types.JavaObjectData;
import org.hsqldb.types.JavaObjectDataInternal; import org.hsqldb.types.JavaObjectDataInternal;
import org.hsqldb.types.TimeData;
import org.hsqldb.types.TimestampData;
import org.hsqldb.types.Type; import org.hsqldb.types.Type;
import org.hsqldb.types.Types; import org.hsqldb.types.Types;
//#ifdef JAVA8 //#ifdef JAVA8
import java.sql.JDBCType; import java.sql.JDBCType;
import java.sql.SQLType; import java.sql.SQLType;
//#endif JAVA8 //#endif JAVA8
/* $Id: JDBCPreparedStatement.java 6565 2022-06-29 14:20:12Z fredt $ */ /* $Id: JDBCPreparedStatement.java 6656 2023-05-29 15:55:53Z fredt $ */
// changes by fredt // changes by fredt
// SimpleDateFormat objects moved out of methods to improve performance // SimpleDateFormat objects moved out of methods to improve performance
// this is safe because only one thread at a time should access a // this is safe because only one thread at a time should access a
// PreparedStatement object until it has finished executing the statement // PreparedStatement object until it has finished executing the statement
// //
// fredt@users 20020215 - patch 517028 by peterhudson@users - method defined // fredt@users 20020215 - patch 517028 by peterhudson@users - method defined
// minor changes by fredt // minor changes by fredt
// fredt@users 20020320 - patch 1.7.0 - JDBC 2 support and error trapping; // fredt@users 20020320 - patch 1.7.0 - JDBC 2 support and error trapping;
// JDBC 2 methods can now be called from jdk 1.1.x // JDBC 2 methods can now be called from jdk 1.1.x
skipping to change at line 230 skipping to change at line 227
* PreparedStatement Object.<p> * PreparedStatement Object.<p>
* *
* (fredt@users)<br> * (fredt@users)<br>
* (campbell-burnet@users)<p> * (campbell-burnet@users)<p>
* *
* </div> * </div>
* <!-- end release-specific documentation --> * <!-- end release-specific documentation -->
* *
* @author Campbell Burnet (campbell-burnet@users dot sourceforge.net) * @author Campbell Burnet (campbell-burnet@users dot sourceforge.net)
* @author Fred Toussi (fredt@users dot sourceforge.net) * @author Fred Toussi (fredt@users dot sourceforge.net)
* @version 2.7.0 * @version 2.7.2
* @since 1.9.0 * @since 1.9.0
* @see JDBCConnection#prepareStatement * @see JDBCConnection#prepareStatement
* @see JDBCResultSet * @see JDBCResultSet
*/ */
public class JDBCPreparedStatement extends JDBCStatementBase public class JDBCPreparedStatement extends JDBCStatementBase
implements PreparedStatement { implements PreparedStatement {
/** /**
* <!-- start generic documentation --> * <!-- start generic documentation -->
* Executes the SQL query in this <code>PreparedStatement</code> object * Executes the SQL query in this <code>PreparedStatement</code> object
skipping to change at line 620 skipping to change at line 617
* </div> * </div>
* <!-- end release-specific documentation --> * <!-- end release-specific documentation -->
* *
* @param parameterIndex the first parameter is 1, the second is 2, ... * @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value * @param x the parameter value
* @exception SQLException if a database access error occurs or * @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code> * this method is called on a closed <code>PreparedStatement</code>
*/ */
public synchronized void setTime(int parameterIndex, public synchronized void setTime(int parameterIndex,
Time x) throws SQLException { Time x) throws SQLException {
setParameter(parameterIndex, x); setTime(parameterIndex, x, null);
} }
/** /**
* <!-- start generic documentation --> * <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Timestamp</code > value. * Sets the designated parameter to the given <code>java.sql.Timestamp</code > value.
* The driver * The driver
* converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the * converts this to an SQL <code>TIMESTAMP</code> value when it sends it to the
* database. * database.
* <!-- end generic documentation --> * <!-- end generic documentation -->
* <div class="ReleaseSpecificDocumentation"> * <div class="ReleaseSpecificDocumentation">
skipping to change at line 650 skipping to change at line 647
* </div> * </div>
* <!-- end release-specific documentation --> * <!-- end release-specific documentation -->
* *
* @param parameterIndex the first parameter is 1, the second is 2, ... * @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value * @param x the parameter value
* @exception SQLException if a database access error occurs or * @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code> * this method is called on a closed <code>PreparedStatement</code>
*/ */
public synchronized void setTimestamp(int parameterIndex, public synchronized void setTimestamp(int parameterIndex,
Timestamp x) throws SQLException { Timestamp x) throws SQLException {
setParameter(parameterIndex, x); setTimestamp(parameterIndex, x, null);
} }
/* @todo 1.9.0 - implement streaming */ /* @todo 1.9.0 - implement streaming */
/** /**
* <!-- start generic documentation --> * <!-- start generic documentation -->
* Sets the designated parameter to the given input stream, which will have * Sets the designated parameter to the given input stream, which will have
* the specified number of bytes. * the specified number of bytes.
* When a very large ASCII value is input to a <code>LONGVARCHAR</code> * When a very large ASCII value is input to a <code>LONGVARCHAR</code>
* parameter, it may be more practical to send it via a * parameter, it may be more practical to send it via a
skipping to change at line 1516 skipping to change at line 1513
int index = parameterIndex - 1; int index = parameterIndex - 1;
if (x == null) { if (x == null) {
parameterValues[index] = null; parameterValues[index] = null;
parameterSet[index] = true; parameterSet[index] = true;
return; return;
} }
Type outType = parameterTypes[index]; Type outType = parameterTypes[index];
Object value;
switch (outType.typeCode) { switch (outType.typeCode) {
case Types.SQL_DATE : case Types.SQL_DATE :
case Types.SQL_TIMESTAMP : case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE : case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
value = ((DateTimeType)outType).convertJavaToSQL(session, x, cal );
break; break;
case Types.SQL_CHAR:
case Types.SQL_VARCHAR:
value = Type.SQL_DATE.convertJavaToSQL(session, x);
value = outType.castToType(session, value, Type.SQL_DATE);
break;
default : default :
throw JDBCUtil.sqlException(ErrorCode.X_42561); throw JDBCUtil.sqlException(ErrorCode.X_42561);
} }
Object value = ((DateTimeType)outType).convertJavaToSQL(session, x, cal)
;
parameterValues[index] = value; parameterValues[index] = value;
parameterSet[index] = true; parameterSet[index] = true;
} }
/** /**
* <!-- start generic documentation --> * <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Time</code> val ue, * Sets the designated parameter to the given <code>java.sql.Time</code> val ue,
* using the given <code>Calendar</code> object. The driver uses * using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIME</code> va lue, * the <code>Calendar</code> object to construct an SQL <code>TIME</code> va lue,
* which the driver then sends to the database. With * which the driver then sends to the database. With
skipping to change at line 1578 skipping to change at line 1582
int index = parameterIndex - 1; int index = parameterIndex - 1;
if (x == null) { if (x == null) {
parameterValues[index] = null; parameterValues[index] = null;
parameterSet[index] = true; parameterSet[index] = true;
return; return;
} }
Type outType = parameterTypes[index]; Type outType = parameterTypes[index];
Object value;
switch (outType.typeCode) { switch (outType.typeCode) {
case Types.SQL_TIME : case Types.SQL_TIME :
case Types.SQL_TIME_WITH_TIME_ZONE : case Types.SQL_TIME_WITH_TIME_ZONE :
case Types.SQL_TIMESTAMP:
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
value = ((DateTimeType)outType).convertJavaToSQL(session, x, cal
);
break;
case Types.SQL_CHAR:
case Types.SQL_VARCHAR:
value = Type.SQL_TIME_WITH_TIME_ZONE_MAX.convertJavaToSQL(sessio
n, x);
value = outType.castToType(session, value, Type.SQL_TIME_WITH_TI
ME_ZONE_MAX);
break; break;
default : default :
throw JDBCUtil.sqlException(ErrorCode.X_42561); throw JDBCUtil.sqlException(ErrorCode.X_42561);
} }
Object value = ((DateTimeType)outType).convertJavaToSQL(session, x, cal)
;
parameterValues[index] = value; parameterValues[index] = value;
parameterSet[index] = true; parameterSet[index] = true;
} }
/** /**
* <!-- start generic documentation --> * <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Timestamp</code > value, * Sets the designated parameter to the given <code>java.sql.Timestamp</code > value,
* using the given <code>Calendar</code> object. The driver uses * using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</cod e> value, * the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</cod e> value,
* which the driver then sends to the database. With a * which the driver then sends to the database. With a
skipping to change at line 1644 skipping to change at line 1657
int index = parameterIndex - 1; int index = parameterIndex - 1;
if (x == null) { if (x == null) {
parameterValues[index] = null; parameterValues[index] = null;
parameterSet[index] = true; parameterSet[index] = true;
return; return;
} }
Type outType = parameterTypes[index]; Type outType = parameterTypes[index];
Object value;
switch (outType.typeCode) { switch (outType.typeCode) {
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
case Types.SQL_TIMESTAMP : case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
case Types.SQL_TIME : case Types.SQL_TIME :
case Types.SQL_TIME_WITH_TIME_ZONE : case Types.SQL_TIME_WITH_TIME_ZONE :
case Types.SQL_DATE : case Types.SQL_DATE :
value = ((DateTimeType)outType).convertJavaToSQL(session, x, cal );
break; break;
case Types.SQL_CHAR:
case Types.SQL_VARCHAR:
value = Type.SQL_TIMESTAMP_WITH_TIME_ZONE_MAX.convertJavaToSQL(s
ession, x);
value = outType.castToType(session, value, Type.SQL_TIMESTAMP_WI
TH_TIME_ZONE_MAX);
break;
default : default :
throw JDBCUtil.sqlException(ErrorCode.X_42561); throw JDBCUtil.sqlException(ErrorCode.X_42561);
} }
Object value = ((DateTimeType)outType).convertJavaToSQL(session, x, cal)
;
parameterValues[index] = value; parameterValues[index] = value;
parameterSet[index] = true; parameterSet[index] = true;
} }
/** /**
* <!-- start generic documentation --> * <!-- start generic documentation -->
* Sets the designated parameter to SQL <code>NULL</code>. * Sets the designated parameter to SQL <code>NULL</code>.
* This version of the method <code>setNull</code> should * This version of the method <code>setNull</code> should
* be used for user-defined types and REF type parameters. Examples * be used for user-defined types and REF type parameters. Examples
* of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and * of user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and
 End of changes. 21 change blocks. 
18 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)