Source Code Cross Referenced for DbPreparedStatement.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » database » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
0003:         * Distributed under the terms of either:
0004:         * - the common development and distribution license (CDDL), v1.0; or
0005:         * - the GNU Lesser General Public License, v2.1 or later
0006:         * $Id: DbPreparedStatement.java 3657 2007-02-15 23:39:06Z gbevin $
0007:         */
0008:        package com.uwyn.rife.database;
0009:
0010:        import com.uwyn.rife.database.exceptions.*;
0011:        import java.sql.*;
0012:
0013:        import com.uwyn.rife.database.queries.Query;
0014:        import com.uwyn.rife.site.Constrained;
0015:        import com.uwyn.rife.site.ConstrainedUtils;
0016:        import com.uwyn.rife.tools.ArrayUtils;
0017:        import com.uwyn.rife.tools.BeanUtils;
0018:        import com.uwyn.rife.tools.exceptions.BeanUtilsException;
0019:        import java.io.InputStream;
0020:        import java.io.Reader;
0021:        import java.math.BigDecimal;
0022:        import java.net.URL;
0023:        import java.util.Calendar;
0024:        import java.util.List;
0025:        import java.util.Map;
0026:
0027:        /**
0028:         * Provides a wrapper around the regular JDBC <code>PreparedStatement</code>
0029:         * class. It can only be instantiated by calling the
0030:         * <code>getPreparedStatement</code> method on an existing
0031:         * <code>DbConnection</code> instance.
0032:         * <p>This class hooks into the database connection pool and cleans up as much
0033:         * as possible in case of errors. The thrown <code>DatabaseException</code>
0034:         * exceptions should thus only be used for error reporting and not for
0035:         * releasing resources used by the framework.
0036:         * <p>The <code>executeQuery</code> method stores its resultset in the
0037:         * executing <code>DbPreparedStatement</code> instance. It's recommended to
0038:         * use the <code>DbQueryManager</code>'s <code>fetch</code> method to process
0039:         * the result set. If needed, one can also use the <code>getResultSet</code>
0040:         * method to manually process the results through plain JDBC. However, when
0041:         * exceptions are thrown during this procedure, it's also the responsability
0042:         * of the user to correctly clean up all resources.
0043:         * <p>Additional methods have been implemented to take advantage of
0044:         * information that is present when one uses query builders to construct the
0045:         * database queries. In this case, parameter values can be set by using column
0046:         * names instead of column numbers and automatic population of a statement
0047:         * from bean property values is also supported.
0048:         *
0049:         * @author Geert Bevin (gbevin[remove] at uwyn dot com)
0050:         * @version $Revision: 3657 $
0051:         * @see #executeQuery()
0052:         * @see #getResultSet()
0053:         * @see com.uwyn.rife.database.DbConnection#getPreparedStatement(String)
0054:         * @see com.uwyn.rife.database.DbQueryManager#fetch(ResultSet, DbRowProcessor)
0055:         * @see com.uwyn.rife.database.queries.Delete
0056:         * @see com.uwyn.rife.database.queries.Insert
0057:         * @see com.uwyn.rife.database.queries.Select
0058:         * @see com.uwyn.rife.database.queries.Update
0059:         * @see java.sql.PreparedStatement
0060:         * @see java.sql.ResultSet
0061:         * @since 1.0
0062:         */
0063:        public class DbPreparedStatement extends DbStatement {
0064:            private String mSql = null;
0065:            private Query mQuery = null;
0066:
0067:            private List<String> mParameterNames = null;
0068:            private VirtualParameters mVirtualParameters = null;
0069:
0070:            /**
0071:             * Constructs a new <code>DbStatement</code> from a SQL query string,
0072:             * a <code>DbConnection</code> and a <code>PreparedStatement</code>.
0073:             * This constructor will never be called by a user of the api. The
0074:             * <code>getPreparedStatement</code> of an existing
0075:             * <code>DbConnection</code> instance should be used instead.
0076:             *
0077:             * @param connection a <code>DbConnection</code> instance
0078:             * @param sql a <code>String</code> with the sql statement
0079:             * @param preparedStatement a JDBC <code>PreparedStatement</code>
0080:             * instance
0081:             * @exception DatabaseException if a database access error occurs
0082:             * @since 1.0
0083:             */
0084:            DbPreparedStatement(DbConnection connection, String sql,
0085:                    PreparedStatement preparedStatement)
0086:                    throws DatabaseException {
0087:                super (connection, preparedStatement);
0088:
0089:                assert connection != null;
0090:                assert sql != null;
0091:                assert sql.length() > 0;
0092:                assert preparedStatement != null;
0093:
0094:                mSql = sql;
0095:                mQuery = null;
0096:            }
0097:
0098:            /**
0099:             * Constructs a new <code>DbStatement</code> from a
0100:             * <code>ParametrizedQuery</code>, a <code>DbConnection</code> and a
0101:             * <code>PreparedStatement</code>. This constructor will never be
0102:             * called by a user of the api. The <code>getPreparedStatement</code>
0103:             * of an existing <code>DbConnection</code> instance should be used
0104:             * instead.
0105:             *
0106:             * @param connection a <code>DbConnection</code> instance
0107:             * @param sql a <code>String</code> with the sql statement
0108:             * @param preparedStatement a JDBC <code>PreparedStatement</code>
0109:             * instance
0110:             * @exception DatabaseException if a database access error occurs
0111:             * @since 1.0
0112:             */
0113:            DbPreparedStatement(DbConnection connection, Query query,
0114:                    PreparedStatement preparedStatement)
0115:                    throws DatabaseException {
0116:                super (connection, preparedStatement);
0117:
0118:                String sql = query.getSql();
0119:
0120:                assert connection != null;
0121:                assert sql != null;
0122:                assert sql.length() > 0;
0123:                assert query != null;
0124:                assert preparedStatement != null;
0125:
0126:                mSql = sql;
0127:                mQuery = query;
0128:            }
0129:
0130:            /**
0131:             * Returns the SQL query that will be executed by this prepared
0132:             * statement.
0133:             *
0134:             * @return a <code>String</code> with the SQL query of this prepared
0135:             * statement
0136:             * @since 1.0
0137:             */
0138:            public String getSql() {
0139:                return mSql;
0140:            }
0141:
0142:            /**
0143:             * Returns the query builder that provides the SQL query that will be
0144:             * executed by this prepared statement.
0145:             *
0146:             * @return a <code>Query</code> object with the query builder
0147:             * instance; or
0148:             * <p><code>null</code> if the prepared statement was initialized from
0149:             * a string SQL query
0150:             * @since 1.0
0151:             */
0152:            public Query getQuery() {
0153:                return mQuery;
0154:            }
0155:
0156:            /**
0157:             * Executes the SQL query in this <code>DbPreparedStatement</code>
0158:             * object. The <code>ResultSet</code> object generated by the query is
0159:             * stored and can be retrieved with the <code>getResultSet</code>
0160:             * method.
0161:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0162:             * is automatically closed and an ongoing transaction will be
0163:             * automatically rolled back if it belongs to the executing thread.
0164:             *
0165:             * @exception DatabaseException if a database access error occurs or
0166:             * the SQL statement does not return a <code>ResultSet</code> object
0167:             * @see #getResultSet()
0168:             * @since 1.0
0169:             */
0170:            public void executeQuery() throws DatabaseException {
0171:                try {
0172:                    waitForConnection();
0173:
0174:                    cleanResultSet();
0175:
0176:                    long start = startTrace();
0177:                    if (mVirtualParameters != null) {
0178:                        mVirtualParameters.callHandler(this );
0179:                    }
0180:                    ResultSet resultset = ((PreparedStatement) mStatement)
0181:                            .executeQuery();
0182:                    outputTrace(start, getSql());
0183:
0184:                    setResultset(resultset);
0185:                    return;
0186:                } catch (SQLException e) {
0187:                    handleException();
0188:                    throw new ExecutionErrorException(mSql, mConnection
0189:                            .getDatasource(), e);
0190:                }
0191:            }
0192:
0193:            /**
0194:             * Executes the SQL statement in this <code>DbPreparedStatement</code>
0195:             * object, which must be an SQL <code>INSERT</code>,
0196:             * <code>UPDATE</code> or <code>DELETE</code> statement; or a SQL
0197:             * statement that returns nothing, such as a DDL statement.
0198:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0199:             * is automatically closed and an ongoing transaction will be
0200:             * automatically rolled back if it belongs to the executing thread.
0201:             *
0202:             * @return the row count for <code>INSERT</code>, <code>UPDATE</code>,
0203:             * or <code>DELETE</code> statements; or
0204:             * <p>0 for SQL statements that return nothing
0205:             * @exception DatabaseException if a database access error occurs or
0206:             * the SQL statement returns a <code>ResultSet</code> object
0207:             * @since 1.0
0208:             */
0209:            public int executeUpdate() throws DatabaseException {
0210:                try {
0211:                    waitForConnection();
0212:
0213:                    long start = startTrace();
0214:                    if (mVirtualParameters != null) {
0215:                        mVirtualParameters.callHandler(this );
0216:                    }
0217:                    int result = ((PreparedStatement) mStatement)
0218:                            .executeUpdate();
0219:                    outputTrace(start, getSql());
0220:
0221:                    return result;
0222:                } catch (SQLException e) {
0223:                    handleException();
0224:                    throw new ExecutionErrorException(mSql, mConnection
0225:                            .getDatasource(), e);
0226:                }
0227:            }
0228:
0229:            /**
0230:             * Adds a set of parameters to this <code>DbPreparedStatement</code>
0231:             * object's batch of commands.
0232:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0233:             * is automatically closed and an ongoing transaction will be
0234:             * automatically rolled back if it belongs to the executing thread.
0235:             *
0236:             * @exception DatabaseException if a database access error occurs
0237:             * @see com.uwyn.rife.database.DbStatement#addBatch
0238:             * @since 1.0
0239:             */
0240:            public void addBatch() throws DatabaseException {
0241:                try {
0242:                    ((PreparedStatement) mStatement).addBatch();
0243:                    traceBatch(mSql);
0244:                } catch (SQLException e) {
0245:                    handleException();
0246:                    throw new DatabaseException(e);
0247:                }
0248:            }
0249:
0250:            /**
0251:             * Releases this <code>DbPreparedStatement</code> object's database
0252:             * and JDBC resources immediately instead of waiting for this to
0253:             * happen when it is automatically closed. It is generally good
0254:             * practice to release resources as soon as you are finished with them
0255:             * to avoid tying up database resources.
0256:             * <p>Calling the method <code>close</code> on a
0257:             * <code>DbPreparedStatement</code> object that is already closed has
0258:             * no effect.
0259:             * <p><b>Note:</b> A <code>DbPreparedStatement</code> object is
0260:             * automatically closed when it is garbage collected. When a
0261:             * <code>DbPreparedStatement</code> object is closed, its current
0262:             * <code>ResultSet</code> object, if one exists, is also closed.
0263:             *
0264:             * @exception DatabaseException if a database access error occurs
0265:             * @since 1.0
0266:             */
0267:            public void close() throws DatabaseException {
0268:                super .close();
0269:            }
0270:
0271:            /**
0272:             * Retrieves a <code>ResultSetMetaData</code> object that contains
0273:             * information about the columns of the <code>ResultSet</code> object
0274:             * that will be returned when this <code>PDbreparedStatement</code>
0275:             * object is executed.
0276:             * <p>Because a <code>DbPreparedStatement</code> object is
0277:             * precompiled, it is possible to know about the
0278:             * <code>ResultSet</code> object that it will return without having to
0279:             * execute it. Consequently, it is possible to invoke the method
0280:             * <code>getMetaData</code> on a <code>DbPreparedStatement</code>
0281:             * object rather than waiting to execute it and then invoking the
0282:             * <code>ResultSet.getMetaData</code> method on the
0283:             * <code>ResultSet</code> object that is returned.
0284:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0285:             * is automatically closed and an ongoing transaction will be
0286:             * automatically rolled back if it belongs to the executing thread.
0287:             * <p><b>NOTE:</b> Using this method may be expensive for some drivers
0288:             * due to the lack of underlying DBMS support.
0289:             *
0290:             * @return the description of a <code>ResultSet</code> object's
0291:             * columns; or
0292:             * <p><code>null</code> if the driver cannot return a
0293:             * <code>ResultSetMetaData</code> object
0294:             * @exception DatabaseException if a database access error occurs
0295:             * @since 1.0
0296:             */
0297:            public ResultSetMetaData getMetaData() throws DatabaseException {
0298:                try {
0299:                    return ((PreparedStatement) mStatement).getMetaData();
0300:                } catch (SQLException e) {
0301:                    handleException();
0302:                    throw new DatabaseException(e);
0303:                }
0304:            }
0305:
0306:            /**
0307:             * Retrieves the number, types and properties of this
0308:             * <code>DbPreparedStatement</code> object's parameters.
0309:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0310:             * is automatically closed and an ongoing transaction will be
0311:             * automatically rolled back if it belongs to the executing thread.
0312:             *
0313:             * @return a <code>ParameterMetaData</code> object that contains
0314:             * information about the number, types and properties of this
0315:             * <code>DbPreparedStatement</code> object's parameters.
0316:             * @exception DatabaseException if a database access error occurs
0317:             * @see java.sql.ParameterMetaData
0318:             * @since 1.0
0319:             */
0320:            public ParameterMetaData getParameterMetaData()
0321:                    throws DatabaseException {
0322:                try {
0323:                    return ((PreparedStatement) mStatement)
0324:                            .getParameterMetaData();
0325:                } catch (SQLException e) {
0326:                    handleException();
0327:                    throw new DatabaseException(e);
0328:                }
0329:            }
0330:
0331:            /**
0332:             * Ensures that this <code>DbPrepareStatement</code> instance has been
0333:             * defined by a valid <code>ParametrizedQuery</code> and initializes
0334:             * all parameter-related instance variables.
0335:             *
0336:             * @exception DatabaseException when this
0337:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0338:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0339:             * the <code>ParametrizedQuery</code> doesn't contain any parameters.
0340:             * @since 1.0
0341:             */
0342:            private void validateParametrizedQuery() throws DatabaseException {
0343:                if (null == mQuery) {
0344:                    throw new NoParametrizedQueryException(this );
0345:                }
0346:
0347:                if (null == mQuery.getParameters()
0348:                        || 0 == mQuery.getParameters().getOrderedNames().size()) {
0349:                    throw new NoParametersException(this );
0350:                }
0351:
0352:                if (null == mParameterNames) {
0353:                    mParameterNames = mQuery.getParameters().getOrderedNames();
0354:                    if (mVirtualParameters != null) {
0355:                        mVirtualParameters.setup(mQuery);
0356:                    }
0357:                }
0358:
0359:            }
0360:
0361:            /**
0362:             * Get the value of a specific virtual parameter.
0363:             *
0364:             * @param name the name of the parameter whose value should be
0365:             * retrieved
0366:             * @return the requested value
0367:             * @exception DatabaseException when an error occurred during the
0368:             * retrieval of the parameter's value
0369:             * @since 1.0
0370:             */
0371:            public Object getVirtualParameterValue(String name)
0372:                    throws UndefinedVirtualParameterException {
0373:                validateParametrizedQuery();
0374:
0375:                int[] virtual_indices = getParameterIndices(name);
0376:
0377:                if (!mVirtualParameters.hasValue(virtual_indices[0])) {
0378:                    throw new UndefinedVirtualParameterException(this , name);
0379:                }
0380:
0381:                return mVirtualParameters.getValue(virtual_indices[0]);
0382:            }
0383:
0384:            /**
0385:             * Get the value of a specific virtual parameter.
0386:             *
0387:             * @param parameterIndex the index of the parameter whose value should
0388:             * be retrieved
0389:             * @return the requested value
0390:             * @exception DatabaseException when an error occurred during the
0391:             * retrieval of the parameter's value
0392:             * @since 1.0
0393:             */
0394:            public Object getVirtualParameterValue(int parameterIndex)
0395:                    throws DatabaseException {
0396:                validateParametrizedQuery();
0397:
0398:                if (!mVirtualParameters.hasValue(parameterIndex)) {
0399:                    throw new UndefinedVirtualParameterException(this ,
0400:                            parameterIndex);
0401:                }
0402:
0403:                return mVirtualParameters.getValue(parameterIndex);
0404:            }
0405:
0406:            /**
0407:             * Automatically retrieves all the values of a bean's properties and
0408:             * sets them for the parameters that have been defined by the
0409:             * <code>ParametrizedQuery</code> object of this
0410:             * <code>DbPrepareStatement</code> instance.
0411:             *
0412:             * @param bean the bean whose properties should be assigned to the
0413:             * query's parameters.
0414:             * @return this <code>DbPreparedStatement</code> instance.
0415:             * @exception DatabaseException when this
0416:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0417:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0418:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0419:             * or if an error occurred during the manipulation of the bean's
0420:             * properties.
0421:             * @since 1.0
0422:             */
0423:            public DbPreparedStatement setBean(Object bean)
0424:                    throws DatabaseException {
0425:                if (null == bean)
0426:                    throw new IllegalArgumentException("bean can't be null.");
0427:
0428:                try {
0429:                    validateParametrizedQuery();
0430:
0431:                    String[] parameters_array = mQuery.getParameters()
0432:                            .getOrderedNamesArray();
0433:
0434:                    Map<String, Class> property_types = BeanUtils
0435:                            .getPropertyTypes(bean.getClass(),
0436:                                    parameters_array, null, null);
0437:                    Map<String, Object> property_values = BeanUtils
0438:                            .getPropertyValues(bean, parameters_array, null,
0439:                                    null);
0440:                    Class property_type = null;
0441:                    Object property_value = null;
0442:                    int parameter_counter = 1;
0443:                    Constrained constrained = ConstrainedUtils
0444:                            .makeConstrainedInstance(bean);
0445:                    for (String parameter_name : mParameterNames) {
0446:                        if (property_types.containsKey(parameter_name)) {
0447:                            property_type = property_types.get(parameter_name);
0448:                            property_value = property_values
0449:                                    .get(parameter_name);
0450:
0451:                            getConnection().getDatasource().getSqlConversion()
0452:                                    .setTypedParameter(this , parameter_counter,
0453:                                            property_type, parameter_name,
0454:                                            property_value, constrained);
0455:                        }
0456:
0457:                        parameter_counter++;
0458:                    }
0459:                } catch (BeanUtilsException e) {
0460:                    handleException();
0461:                    throw new DatabaseException(e);
0462:                }
0463:
0464:                return this ;
0465:            }
0466:
0467:            /**
0468:             * Sets the parameters that should be handled as virtual parameters.
0469:             * These parameters are not sent to the backend, but their values will
0470:             * be stored in this <code>DbPreparedStatement</code> instance for
0471:             * retrieval by other functionalities like capabilities.
0472:             *
0473:             * @param parameters the <code>VirtualParameters</code> instance that
0474:             * will determine the virtual parameters
0475:             * @since 1.0
0476:             */
0477:            public void setVirtualParameters(VirtualParameters parameters) {
0478:                mParameterNames = null;
0479:                mVirtualParameters = parameters;
0480:            }
0481:
0482:            /**
0483:             * Retrieves all the parameter indices that correspond to the name of
0484:             * a parameter of the <code>ParametrizedQuery</code> object that is
0485:             * used by this <code>DbPreparedStatement</code> instance.
0486:             *
0487:             * @param parameterName the name of the parameter that should be
0488:             * looked up
0489:             * @return an <code>int</code> array with all the corresponding
0490:             * indices
0491:             * @exception DatabaseException when this
0492:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0493:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0494:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0495:             * or if no parameters with this name could be found.
0496:             * @since 1.0
0497:             */
0498:            public int[] getParameterIndices(String parameterName)
0499:                    throws DatabaseException {
0500:                if (null == parameterName)
0501:                    throw new IllegalArgumentException(
0502:                            "parameterName can't be null.");
0503:                if (0 == parameterName.length())
0504:                    throw new IllegalArgumentException(
0505:                            "parameterName can't be empty.");
0506:
0507:                validateParametrizedQuery();
0508:
0509:                int parameter_index = 1;
0510:                int[] parameter_indices = new int[0];
0511:                for (String parameter_name : mParameterNames) {
0512:                    if (parameter_name.equals(parameterName)) {
0513:                        parameter_indices = ArrayUtils.join(parameter_indices,
0514:                                parameter_index);
0515:                    }
0516:
0517:                    parameter_index++;
0518:                }
0519:
0520:                if (0 == parameter_indices.length) {
0521:                    throw new ParameterDoesntExistException(this , parameterName);
0522:                }
0523:
0524:                return parameter_indices;
0525:            }
0526:
0527:            /**
0528:             * Sets the named parameters to the given Java <code>double</code>
0529:             * value. The driver converts this to a SQL <code>DOUBLE</code> value
0530:             * when it sends it to the database.
0531:             * <p>If a database access error occurs, this
0532:             * <code>DbPreparedStatement</code> instance is automatically closed.
0533:             *
0534:             * @param parameterName the name of the parameters that have to be set
0535:             * @param x the parameter value
0536:             * @return this <code>DbPreparedStatement</code> instance.
0537:             * @exception DatabaseException when this
0538:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0539:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0540:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0541:             * or if no parameters with this name could be found, or if a database
0542:             * access error occurs.
0543:             * @see #setDoubles(int[], double)
0544:             * @see #setDouble(int, double)
0545:             * @since 1.0
0546:             */
0547:            public DbPreparedStatement setDouble(String parameterName, double x)
0548:                    throws DatabaseException {
0549:                setDoubles(getParameterIndices(parameterName), x);
0550:
0551:                return this ;
0552:            }
0553:
0554:            /**
0555:             * Sets the designated parameters to the given Java
0556:             * <code>double</code> value. The driver converts this to a SQL
0557:             * <code>DOUBLE</code> value when it sends it to the database.
0558:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0559:             * is automatically closed and an ongoing transaction will be
0560:             * automatically rolled back if it belongs to the executing thread.
0561:             *
0562:             * @param parameterIndices the first parameter is 1, the second is 2,
0563:             * ...
0564:             * @param x the parameter value
0565:             * @return this <code>DbPreparedStatement</code> instance.
0566:             * @exception DatabaseException if a database access error occurs
0567:             * @see #setDouble(String, double)
0568:             * @see #setDouble(int, double)
0569:             * @since 1.0
0570:             */
0571:            public DbPreparedStatement setDoubles(int[] parameterIndices,
0572:                    double x) throws DatabaseException {
0573:                if (null == parameterIndices)
0574:                    throw new IllegalArgumentException(
0575:                            "parameterIndices can't be null.");
0576:
0577:                for (int parameter_index : parameterIndices) {
0578:                    setDouble(parameter_index, x);
0579:                }
0580:
0581:                return this ;
0582:            }
0583:
0584:            /**
0585:             * Sets the designated parameter to the given Java <code>double</code>
0586:             * value. The driver converts this to a SQL <code>DOUBLE</code> value
0587:             * when it sends it to the database.
0588:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0589:             * is automatically closed and an ongoing transaction will be
0590:             * automatically rolled back if it belongs to the executing thread.
0591:             *
0592:             * @param parameterIndex the first parameter is 1, the second is 2,
0593:             * ...
0594:             * @param x the parameter value
0595:             * @return this <code>DbPreparedStatement</code> instance.
0596:             * @exception DatabaseException if a database access error occurs
0597:             * @see #setDouble(String, double)
0598:             * @see #setDoubles(int[], double)
0599:             * @since 1.0
0600:             */
0601:            public DbPreparedStatement setDouble(int parameterIndex, double x)
0602:                    throws DatabaseException {
0603:                // handle virtual parameters
0604:                if (mVirtualParameters != null
0605:                        && mVirtualParameters.hasParameter(parameterIndex)) {
0606:                    int real_index = mVirtualParameters
0607:                            .getRealIndex(parameterIndex);
0608:                    if (-1 == real_index) {
0609:                        mVirtualParameters.putValue(parameterIndex, x);
0610:                        return this ;
0611:                    } else {
0612:                        parameterIndex = real_index;
0613:                    }
0614:                }
0615:
0616:                // set the real parameter
0617:                try {
0618:                    ((PreparedStatement) mStatement).setDouble(parameterIndex,
0619:                            x);
0620:                } catch (SQLException e) {
0621:                    handleException();
0622:                    throw new DatabaseException(e);
0623:                }
0624:
0625:                return this ;
0626:            }
0627:
0628:            /**
0629:             * Sets the named parameters to the given Java <code>short</code>
0630:             * value. The driver converts this to a SQL <code>SMALLINT</code>
0631:             * value when it sends it to the database.
0632:             * <p>If a database access error occurs, this
0633:             * <code>DbPreparedStatement</code> instance is automatically closed.
0634:             *
0635:             * @param parameterName the name of the parameters that have to be set
0636:             * @param x the parameter value
0637:             * @return this <code>DbPreparedStatement</code> instance.
0638:             * @exception DatabaseException when this
0639:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0640:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0641:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0642:             * or if no parameters with this name could be found, or if a database
0643:             * access error occurs.
0644:             * @see #setShorts(int[], short)
0645:             * @see #setShort(int, short)
0646:             * @since 1.0
0647:             */
0648:            public DbPreparedStatement setShort(String parameterName, short x)
0649:                    throws DatabaseException {
0650:                setShorts(getParameterIndices(parameterName), x);
0651:
0652:                return this ;
0653:            }
0654:
0655:            /**
0656:             * Sets the designated parameters to the given Java <code>short</code>
0657:             * value. The driver converts this to a SQL <code>SMALLINT</code>
0658:             * value when it sends it to the database.
0659:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0660:             * is automatically closed and an ongoing transaction will be
0661:             * automatically rolled back if it belongs to the executing thread.
0662:             *
0663:             * @param parameterIndices the first parameter is 1, the second is 2,
0664:             * ...
0665:             * @param x the parameter value
0666:             * @return this <code>DbPreparedStatement</code> instance.
0667:             * @exception DatabaseException if a database access error occurs
0668:             * @see #setShort(String, short)
0669:             * @see #setShort(int, short)
0670:             * @since 1.0
0671:             */
0672:            public DbPreparedStatement setShorts(int[] parameterIndices, short x)
0673:                    throws DatabaseException {
0674:                if (null == parameterIndices)
0675:                    throw new IllegalArgumentException(
0676:                            "parameterIndices can't be null.");
0677:
0678:                for (int parameter_index : parameterIndices) {
0679:                    setShort(parameter_index, x);
0680:                }
0681:
0682:                return this ;
0683:            }
0684:
0685:            /**
0686:             * Sets the designated parameter to the given Java <code>short</code>
0687:             * value. The driver converts this to a SQL <code>SMALLINT</code>
0688:             * value when it sends it to the database.
0689:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0690:             * is automatically closed and an ongoing transaction will be
0691:             * automatically rolled back if it belongs to the executing thread.
0692:             *
0693:             * @param parameterIndex the first parameter is 1, the second is 2,
0694:             * ...
0695:             * @param x the parameter value
0696:             * @return this <code>DbPreparedStatement</code> instance.
0697:             * @exception DatabaseException if a database access error occurs
0698:             * @see #setShort(String, short)
0699:             * @see #setShorts(int[], short)
0700:             * @since 1.0
0701:             */
0702:            public DbPreparedStatement setShort(int parameterIndex, short x)
0703:                    throws DatabaseException {
0704:                // handle virtual parameters
0705:                if (mVirtualParameters != null
0706:                        && mVirtualParameters.hasParameter(parameterIndex)) {
0707:                    int real_index = mVirtualParameters
0708:                            .getRealIndex(parameterIndex);
0709:                    if (-1 == real_index) {
0710:                        mVirtualParameters.putValue(parameterIndex, x);
0711:                        return this ;
0712:                    } else {
0713:                        parameterIndex = real_index;
0714:                    }
0715:                }
0716:
0717:                // set the real parameter
0718:                try {
0719:                    ((PreparedStatement) mStatement)
0720:                            .setShort(parameterIndex, x);
0721:                } catch (SQLException e) {
0722:                    handleException();
0723:                    throw new DatabaseException(e);
0724:                }
0725:
0726:                return this ;
0727:            }
0728:
0729:            /**
0730:             * Sets the named parameters to SQL <code>NULL</code>.
0731:             * <p>If a database access error occurs, this
0732:             * <code>DbPreparedStatement</code> instance is automatically closed.
0733:             * <p><b>Note:</b> You must specify the parameter's SQL type.
0734:             *
0735:             * @param parameterName the name of the parameters that have to be set
0736:             * @param sqlType the SQL type code defined in
0737:             * <code>java.sql.Types</code>
0738:             * @return this <code>DbPreparedStatement</code> instance.
0739:             * @exception DatabaseException when this
0740:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0741:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0742:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0743:             * or if no parameters with this name could be found, or if a database
0744:             * access error occurs.
0745:             * @see java.sql.Types
0746:             * @see #setNulls(int[], int)
0747:             * @see #setNull(int, int)
0748:             * @since 1.0
0749:             */
0750:            public DbPreparedStatement setNull(String parameterName, int sqlType)
0751:                    throws DatabaseException {
0752:                setNulls(getParameterIndices(parameterName), sqlType);
0753:
0754:                return this ;
0755:            }
0756:
0757:            /**
0758:             * Sets the designated parameters to SQL <code>NULL</code>.
0759:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0760:             * is automatically closed and an ongoing transaction will be
0761:             * automatically rolled back if it belongs to the executing thread.
0762:             * <p><b>Note:</b> You must specify the parameter's SQL type.
0763:             *
0764:             * @param parameterIndices the first parameter is 1, the second is 2,
0765:             * ...
0766:             * @param sqlType the SQL type code defined in
0767:             * <code>java.sql.Types</code>
0768:             * @return this <code>DbPreparedStatement</code> instance.
0769:             * @exception DatabaseException if a database access error occurs
0770:             * @see java.sql.Types
0771:             * @see #setNull(String, int)
0772:             * @see #setNull(int, int)
0773:             * @since 1.0
0774:             */
0775:            public DbPreparedStatement setNulls(int[] parameterIndices,
0776:                    int sqlType) throws DatabaseException {
0777:                if (null == parameterIndices)
0778:                    throw new IllegalArgumentException(
0779:                            "parameterIndices can't be null.");
0780:
0781:                for (int parameter_index : parameterIndices) {
0782:                    setNull(parameter_index, sqlType);
0783:                }
0784:
0785:                return this ;
0786:            }
0787:
0788:            /**
0789:             * Sets the designated parameter to SQL <code>NULL</code>.
0790:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0791:             * is automatically closed and an ongoing transaction will be
0792:             * automatically rolled back if it belongs to the executing thread.
0793:             * <p><b>Note:</b> You must specify the parameter's SQL type.
0794:             *
0795:             * @param parameterIndex the first parameter is 1, the second is 2,
0796:             * ...
0797:             * @param sqlType the SQL type code defined in
0798:             * <code>java.sql.Types</code>
0799:             * @return this <code>DbPreparedStatement</code> instance.
0800:             * @exception DatabaseException if a database access error occurs
0801:             * @see java.sql.Types
0802:             * @see #setNull(String, int)
0803:             * @see #setNulls(int[], int)
0804:             * @since 1.0
0805:             */
0806:            public DbPreparedStatement setNull(int parameterIndex, int sqlType)
0807:                    throws DatabaseException {
0808:                // handle virtual parameters
0809:                if (mVirtualParameters != null
0810:                        && mVirtualParameters.hasParameter(parameterIndex)) {
0811:                    int real_index = mVirtualParameters
0812:                            .getRealIndex(parameterIndex);
0813:                    if (-1 == real_index) {
0814:                        mVirtualParameters.putValue(parameterIndex, null);
0815:                        return this ;
0816:                    } else {
0817:                        parameterIndex = real_index;
0818:                    }
0819:                }
0820:
0821:                // set the real parameter
0822:                try {
0823:                    ((PreparedStatement) mStatement).setNull(parameterIndex,
0824:                            sqlType);
0825:                } catch (SQLException e) {
0826:                    handleException();
0827:                    throw new DatabaseException(e);
0828:                }
0829:
0830:                return this ;
0831:            }
0832:
0833:            /**
0834:             * Sets the named parameters to SQL <code>NULL</code>. This version of
0835:             * the method <code>setNull</code> should be used for user-defined
0836:             * types and REF type parameters. Examples of user-defined types
0837:             * include: STRUCT, DISTINCT, JAVA_OBJECT, and named array types.
0838:             * <p><b>Note:</b> To be portable, applications must give the SQL type
0839:             * code and the fully-qualified SQL type name when specifying a NULL
0840:             * user-defined or REF parameter. In the case of a user-defined type
0841:             * the name is the type name of the parameter itself. For a REF
0842:             * parameter, the name is the type name of the referenced type. If a
0843:             * JDBC driver does not need the type code or type name information,
0844:             * it may ignore it.
0845:             * <p>Although it is intended for user-defined and Ref parameters,
0846:             * this method may be used to set a null parameter of any JDBC type.
0847:             * If the parameter does not have a user-defined or REF type, the
0848:             * given typeName is ignored.
0849:             * <p>If a database access error occurs, this
0850:             * <code>DbPreparedStatement</code> instance is automatically closed.
0851:             *
0852:             * @param parameterName the name of the parameters that have to be set
0853:             * @param sqlType a value from <code>java.sql.Types</code>
0854:             * @param typeName the fully-qualified name of an SQL user-defined
0855:             * type; ignored if the parameter is not a user-defined type or REF
0856:             * @return this <code>DbPreparedStatement</code> instance.
0857:             * @exception DatabaseException when this
0858:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0859:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0860:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0861:             * or if no parameters with this name could be found, or if a database
0862:             * access error occurs.
0863:             * @see java.sql.Types
0864:             * @see #setNulls(int[], int, String)
0865:             * @see #setNull(int, int, String)
0866:             * @since 1.0
0867:             */
0868:            public DbPreparedStatement setNull(String parameterName,
0869:                    int sqlType, String typeName) throws DatabaseException {
0870:                setNulls(getParameterIndices(parameterName), sqlType, typeName);
0871:
0872:                return this ;
0873:            }
0874:
0875:            /**
0876:             * Sets the designated parameters to SQL <code>NULL</code>. This
0877:             * version of the method <code>setNull</code> should be used for
0878:             * user-defined types and REF type parameters. Examples of
0879:             * user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and
0880:             * named array types.
0881:             * <p><b>Note:</b> To be portable, applications must give the SQL type
0882:             * code and the fully-qualified SQL type name when specifying a NULL
0883:             * user-defined or REF parameter. In the case of a user-defined type
0884:             * the name is the type name of the parameter itself. For a REF
0885:             * parameter, the name is the type name of the referenced type. If a
0886:             * JDBC driver does not need the type code or type name information,
0887:             * it may ignore it.
0888:             * <p>Although it is intended for user-defined and Ref parameters,
0889:             * this method may be used to set a null parameter of any JDBC type.
0890:             * If the parameter does not have a user-defined or REF type, the
0891:             * given typeName is ignored.
0892:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0893:             * is automatically closed and an ongoing transaction will be
0894:             * automatically rolled back if it belongs to the executing thread.
0895:             *
0896:             * @param parameterIndices the first parameter is 1, the second is 2,
0897:             * ...
0898:             * @param sqlType a value from <code>java.sql.Types</code>
0899:             * @param typeName the fully-qualified name of an SQL user-defined
0900:             * type; ignored if the parameter is not a user-defined type or REF
0901:             * @return this <code>DbPreparedStatement</code> instance.
0902:             * @exception DatabaseException if a database access error occurs
0903:             * @see java.sql.Types
0904:             * @see #setNull(String, int, String)
0905:             * @see #setNull(int, int, String)
0906:             * @since 1.0
0907:             */
0908:            public DbPreparedStatement setNulls(int[] parameterIndices,
0909:                    int sqlType, String typeName) throws DatabaseException {
0910:                if (null == parameterIndices)
0911:                    throw new IllegalArgumentException(
0912:                            "parameterIndices can't be null.");
0913:
0914:                for (int parameter_index : parameterIndices) {
0915:                    setNull(parameter_index, sqlType, typeName);
0916:                }
0917:
0918:                return this ;
0919:            }
0920:
0921:            /**
0922:             * Sets the designated parameter to SQL <code>NULL</code>. This
0923:             * version of the method <code>setNull</code> should be used for
0924:             * user-defined types and REF type parameters. Examples of
0925:             * user-defined types include: STRUCT, DISTINCT, JAVA_OBJECT, and
0926:             * named array types.
0927:             * <p><b>Note:</b> To be portable, applications must give the SQL type
0928:             * code and the fully-qualified SQL type name when specifying a NULL
0929:             * user-defined or REF parameter. In the case of a user-defined type
0930:             * the name is the type name of the parameter itself. For a REF
0931:             * parameter, the name is the type name of the referenced type. If a
0932:             * JDBC driver does not need the type code or type name information,
0933:             * it may ignore it.
0934:             * <p>Although it is intended for user-defined and Ref parameters,
0935:             * this method may be used to set a null parameter of any JDBC type.
0936:             * If the parameter does not have a user-defined or REF type, the
0937:             * given typeName is ignored.
0938:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
0939:             * is automatically closed and an ongoing transaction will be
0940:             * automatically rolled back if it belongs to the executing thread.
0941:             *
0942:             * @param parameterIndex the first parameter is 1, the second is 2,
0943:             * ...
0944:             * @param sqlType a value from <code>java.sql.Types</code>
0945:             * @param typeName the fully-qualified name of an SQL user-defined
0946:             * type; ignored if the parameter is not a user-defined type or REF
0947:             * @return this <code>DbPreparedStatement</code> instance.
0948:             * @exception DatabaseException if a database access error occurs
0949:             * @see java.sql.Types
0950:             * @see #setNull(String, int, String)
0951:             * @see #setNulls(int[], int, String)
0952:             * @since 1.0
0953:             */
0954:            public DbPreparedStatement setNull(int parameterIndex, int sqlType,
0955:                    String typeName) throws DatabaseException {
0956:                // handle virtual parameters
0957:                if (mVirtualParameters != null
0958:                        && mVirtualParameters.hasParameter(parameterIndex)) {
0959:                    int real_index = mVirtualParameters
0960:                            .getRealIndex(parameterIndex);
0961:                    if (-1 == real_index) {
0962:                        mVirtualParameters.putValue(parameterIndex, null);
0963:                        return this ;
0964:                    } else {
0965:                        parameterIndex = real_index;
0966:                    }
0967:                }
0968:
0969:                // set the real parameter
0970:                try {
0971:                    ((PreparedStatement) mStatement).setNull(parameterIndex,
0972:                            sqlType, typeName);
0973:                } catch (SQLException e) {
0974:                    handleException();
0975:                    throw new DatabaseException(e);
0976:                }
0977:
0978:                return this ;
0979:            }
0980:
0981:            /**
0982:             * Sets the named parameters to the given Java <code>boolean</code>
0983:             * value. The driver converts this to a SQL <code>BIT</code> value
0984:             * when it sends it to the database.
0985:             * <p>If a database access error occurs, this
0986:             * <code>DbPreparedStatement</code> instance is automatically closed.
0987:             *
0988:             * @param parameterName the name of the parameters that have to be set
0989:             * @param x the parameter value
0990:             * @return this <code>DbPreparedStatement</code> instance.
0991:             * @exception DatabaseException when this
0992:             * <code>DbPrepareStatement</code> instance wasn't defined by a
0993:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
0994:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
0995:             * or if no parameters with this name could be found, or if a database
0996:             * access error occurs.
0997:             * @see #setBoolean(String, boolean)
0998:             * @see #setBooleans(int[], boolean)
0999:             * @since 1.0
1000:             */
1001:            public DbPreparedStatement setBoolean(String parameterName,
1002:                    boolean x) throws DatabaseException {
1003:                setBooleans(getParameterIndices(parameterName), x);
1004:
1005:                return this ;
1006:            }
1007:
1008:            /**
1009:             * Sets the designated parameters to the given Java
1010:             * <code>boolean</code> value. The driver converts this to a SQL
1011:             * <code>BIT</code> value when it sends it to the database.
1012:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1013:             * is automatically closed and an ongoing transaction will be
1014:             * automatically rolled back if it belongs to the executing thread.
1015:             *
1016:             * @param parameterIndices the first parameter is 1, the second is 2,
1017:             * ...
1018:             * @param x the parameter value
1019:             * @return this <code>DbPreparedStatement</code> instance.
1020:             * @exception DatabaseException if a database access error occurs
1021:             * @see #setBoolean(String, boolean)
1022:             * @see #setBoolean(int, boolean)
1023:             * @since 1.0
1024:             */
1025:            public DbPreparedStatement setBooleans(int[] parameterIndices,
1026:                    boolean x) throws DatabaseException {
1027:                if (null == parameterIndices)
1028:                    throw new IllegalArgumentException(
1029:                            "parameterIndices can't be null.");
1030:
1031:                for (int parameter_index : parameterIndices) {
1032:                    setBoolean(parameter_index, x);
1033:                }
1034:
1035:                return this ;
1036:            }
1037:
1038:            /**
1039:             * Sets the designated parameter to the given Java
1040:             * <code>boolean</code> value. The driver converts this to a SQL
1041:             * <code>BIT</code> value when it sends it to the database.
1042:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1043:             * is automatically closed and an ongoing transaction will be
1044:             * automatically rolled back if it belongs to the executing thread.
1045:             *
1046:             * @param parameterIndex the first parameter is 1, the second is 2,
1047:             * ...
1048:             * @param x the parameter value
1049:             * @return this <code>DbPreparedStatement</code> instance.
1050:             * @exception DatabaseException if a database access error occurs
1051:             * @see #setBoolean(String, boolean)
1052:             * @see #setBooleans(int[], boolean)
1053:             * @since 1.0
1054:             */
1055:            public DbPreparedStatement setBoolean(int parameterIndex, boolean x)
1056:                    throws DatabaseException {
1057:                // handle virtual parameters
1058:                if (mVirtualParameters != null
1059:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1060:                    int real_index = mVirtualParameters
1061:                            .getRealIndex(parameterIndex);
1062:                    if (-1 == real_index) {
1063:                        mVirtualParameters.putValue(parameterIndex, x);
1064:                        return this ;
1065:                    } else {
1066:                        parameterIndex = real_index;
1067:                    }
1068:                }
1069:
1070:                // set the real parameter
1071:                try {
1072:                    ((PreparedStatement) mStatement).setBoolean(parameterIndex,
1073:                            x);
1074:                } catch (SQLException e) {
1075:                    handleException();
1076:                    throw new DatabaseException(e);
1077:                }
1078:
1079:                return this ;
1080:            }
1081:
1082:            /**
1083:             * Sets the named parameters to the given Java <code>byte</code>
1084:             * value. The driver converts this to a SQL <code>TINYINT</code> value
1085:             * when it sends it to the database.
1086:             * <p>If a database access error occurs, this
1087:             * <code>DbPreparedStatement</code> instance is automatically closed.
1088:             *
1089:             * @param parameterName the name of the parameters that have to be set
1090:             * @param x the parameter value
1091:             * @return this <code>DbPreparedStatement</code> instance.
1092:             * @exception DatabaseException when this
1093:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1094:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1095:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1096:             * or if no parameters with this name could be found, or if a database
1097:             * access error occurs.
1098:             * @see #setByte(int, byte)
1099:             * @see #setBytes(int[], byte)
1100:             * @since 1.0
1101:             */
1102:            public DbPreparedStatement setByte(String parameterName, byte x)
1103:                    throws DatabaseException {
1104:                setBytes(getParameterIndices(parameterName), x);
1105:
1106:                return this ;
1107:            }
1108:
1109:            /**
1110:             * Sets the designated parameters to the given Java <code>byte</code>
1111:             * value. The driver converts this to a SQL <code>TINYINT</code> value
1112:             * when it sends it to the database.
1113:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1114:             * is automatically closed and an ongoing transaction will be
1115:             * automatically rolled back if it belongs to the executing thread.
1116:             *
1117:             * @param parameterIndices the first parameter is 1, the second is 2,
1118:             * ...
1119:             * @param x the parameter value
1120:             * @return this <code>DbPreparedStatement</code> instance.
1121:             * @exception DatabaseException if a database access error occurs
1122:             * @see #setByte(String, byte)
1123:             * @see #setByte(int, byte)
1124:             * @since 1.0
1125:             */
1126:            public DbPreparedStatement setBytes(int[] parameterIndices, byte x)
1127:                    throws DatabaseException {
1128:                if (null == parameterIndices)
1129:                    throw new IllegalArgumentException(
1130:                            "parameterIndices can't be null.");
1131:
1132:                for (int parameter_index : parameterIndices) {
1133:                    setByte(parameter_index, x);
1134:                }
1135:
1136:                return this ;
1137:            }
1138:
1139:            /**
1140:             * Sets the designated parameter to the given Java <code>byte</code>
1141:             * value. The driver converts this to a SQL <code>TINYINT</code> value
1142:             * when it sends it to the database.
1143:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1144:             * is automatically closed and an ongoing transaction will be
1145:             * automatically rolled back if it belongs to the executing thread.
1146:             *
1147:             * @param parameterIndex the first parameter is 1, the second is 2,
1148:             * ...
1149:             * @param x the parameter value
1150:             * @return this <code>DbPreparedStatement</code> instance.
1151:             * @exception DatabaseException if a database access error occurs
1152:             * @see #setByte(String, byte)
1153:             * @see #setBytes(int[], byte)
1154:             * @since 1.0
1155:             */
1156:            public DbPreparedStatement setByte(int parameterIndex, byte x)
1157:                    throws DatabaseException {
1158:                // handle virtual parameters
1159:                if (mVirtualParameters != null
1160:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1161:                    int real_index = mVirtualParameters
1162:                            .getRealIndex(parameterIndex);
1163:                    if (-1 == real_index) {
1164:                        mVirtualParameters.putValue(parameterIndex, x);
1165:                        return this ;
1166:                    } else {
1167:                        parameterIndex = real_index;
1168:                    }
1169:                }
1170:
1171:                // set the real parameter
1172:                try {
1173:                    ((PreparedStatement) mStatement).setByte(parameterIndex, x);
1174:                } catch (SQLException e) {
1175:                    handleException();
1176:                    throw new DatabaseException(e);
1177:                }
1178:
1179:                return this ;
1180:            }
1181:
1182:            /**
1183:             * Sets the named parameters to the given <code>java.sql.Date</code>
1184:             * value. The driver converts this to a SQL <code>DATE</code> value
1185:             * when it sends it to the database.
1186:             * <p>If a database access error occurs, this
1187:             * <code>DbPreparedStatement</code> instance is automatically closed.
1188:             *
1189:             * @param parameterName the name of the parameters that have to be set
1190:             * @param x the parameter value
1191:             * @return this <code>DbPreparedStatement</code> instance.
1192:             * @exception DatabaseException when this
1193:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1194:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1195:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1196:             * or if no parameters with this name could be found, or if a database
1197:             * access error occurs.
1198:             * @see #setDates(int[], Date)
1199:             * @see #setDate(int, Date)
1200:             * @since 1.0
1201:             */
1202:            public DbPreparedStatement setDate(String parameterName, Date x)
1203:                    throws DatabaseException {
1204:                setDates(getParameterIndices(parameterName), x);
1205:
1206:                return this ;
1207:            }
1208:
1209:            /**
1210:             * Sets the designated parameters to the given
1211:             * <code>java.sql.Date</code> value. The driver converts this to a SQL
1212:             * <code>DATE</code> value when it sends it to the database.
1213:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1214:             * is automatically closed and an ongoing transaction will be
1215:             * automatically rolled back if it belongs to the executing thread.
1216:             *
1217:             * @param parameterIndices the first parameter is 1, the second is 2,
1218:             * ...
1219:             * @param x the parameter value
1220:             * @return this <code>DbPreparedStatement</code> instance.
1221:             * @exception DatabaseException if a database access error occurs
1222:             * @see #setDate(String, Date)
1223:             * @see #setDate(int, Date)
1224:             * @since 1.0
1225:             */
1226:            public DbPreparedStatement setDates(int[] parameterIndices, Date x)
1227:                    throws DatabaseException {
1228:                if (null == parameterIndices)
1229:                    throw new IllegalArgumentException(
1230:                            "parameterIndices can't be null.");
1231:
1232:                for (int parameter_index : parameterIndices) {
1233:                    setDate(parameter_index, x);
1234:                }
1235:
1236:                return this ;
1237:            }
1238:
1239:            /**
1240:             * Sets the designated parameter to the given
1241:             * <code>java.sql.Date</code> value. The driver converts this to a SQL
1242:             * <code>DATE</code> value when it sends it to the database.
1243:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1244:             * is automatically closed and an ongoing transaction will be
1245:             * automatically rolled back if it belongs to the executing thread.
1246:             *
1247:             * @param parameterIndex the first parameter is 1, the second is 2,
1248:             * ...
1249:             * @param x the parameter value
1250:             * @return this <code>DbPreparedStatement</code> instance.
1251:             * @exception DatabaseException if a database access error occurs
1252:             * @see #setDate(String, Date)
1253:             * @see #setDates(int[], Date)
1254:             * @since 1.0
1255:             */
1256:            public DbPreparedStatement setDate(int parameterIndex, Date x)
1257:                    throws DatabaseException {
1258:                // handle virtual parameters
1259:                if (mVirtualParameters != null
1260:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1261:                    int real_index = mVirtualParameters
1262:                            .getRealIndex(parameterIndex);
1263:                    if (-1 == real_index) {
1264:                        mVirtualParameters.putValue(parameterIndex, x);
1265:                        return this ;
1266:                    } else {
1267:                        parameterIndex = real_index;
1268:                    }
1269:                }
1270:
1271:                // set the real parameter
1272:                try {
1273:                    ((PreparedStatement) mStatement).setDate(parameterIndex, x);
1274:                } catch (SQLException e) {
1275:                    handleException();
1276:                    throw new DatabaseException(e);
1277:                }
1278:
1279:                return this ;
1280:            }
1281:
1282:            /**
1283:             * Sets the named parameters to the given <code>java.sql.Date</code>
1284:             * value, using the given <code>Calendar</code> object. The driver
1285:             * uses the <code>Calendar</code> object to construct an SQL
1286:             * <code>DATE</code> value, which the driver then sends to the
1287:             * database. With a <code>Calendar</code> object, the driver can
1288:             * calculate the date taking into account a custom timezone. If no
1289:             * <code>Calendar</code> object is specified, the driver uses the
1290:             * default timezone, which is that of the virtual machine running the
1291:             * application.
1292:             * <p>If a database access error occurs, this
1293:             * <code>DbPreparedStatement</code> instance is automatically closed.
1294:             *
1295:             * @param parameterName the name of the parameters that have to be set
1296:             * @param x the parameter value
1297:             * @param cal the <code>Calendar</code> object the driver will use to
1298:             * construct the date
1299:             * @return this <code>DbPreparedStatement</code> instance.
1300:             * @exception DatabaseException when this
1301:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1302:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1303:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1304:             * or if no parameters with this name could be found, or if a database
1305:             * access error occurs.
1306:             * @see #setDates(int[], Date, Calendar)
1307:             * @see #setDate(int, Date, Calendar)
1308:             * @since 1.0
1309:             */
1310:            public DbPreparedStatement setDate(String parameterName, Date x,
1311:                    Calendar cal) throws DatabaseException {
1312:                setDates(getParameterIndices(parameterName), x, cal);
1313:
1314:                return this ;
1315:            }
1316:
1317:            /**
1318:             * Sets the designated parameters to the given
1319:             * <code>java.sql.Date</code> value, using the given
1320:             * <code>Calendar</code> object. The driver uses the
1321:             * <code>Calendar</code> object to construct an SQL <code>DATE</code>
1322:             * value, which the driver then sends to the database. With a
1323:             * <code>Calendar</code> object, the driver can calculate the date
1324:             * taking into account a custom timezone. If no <code>Calendar</code>
1325:             * object is specified, the driver uses the default timezone, which is
1326:             * that of the virtual machine running the application.
1327:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1328:             * is automatically closed and an ongoing transaction will be
1329:             * automatically rolled back if it belongs to the executing thread.
1330:             *
1331:             * @param parameterIndices the first parameter is 1, the second is 2,
1332:             * ...
1333:             * @param x the parameter value
1334:             * @param cal the <code>Calendar</code> object the driver will use to
1335:             * construct the date
1336:             * @return this <code>DbPreparedStatement</code> instance.
1337:             * @exception DatabaseException if a database access error occurs
1338:             * @see #setDate(String, Date, Calendar)
1339:             * @see #setDate(int, Date, Calendar)
1340:             * @since 1.0
1341:             */
1342:            public DbPreparedStatement setDates(int[] parameterIndices, Date x,
1343:                    Calendar cal) throws DatabaseException {
1344:                if (null == parameterIndices)
1345:                    throw new IllegalArgumentException(
1346:                            "parameterIndices can't be null.");
1347:
1348:                for (int parameter_index : parameterIndices) {
1349:                    setDate(parameter_index, x, cal);
1350:                }
1351:
1352:                return this ;
1353:            }
1354:
1355:            /**
1356:             * Sets the designated parameter to the given
1357:             * <code>java.sql.Date</code> value, using the given
1358:             * <code>Calendar</code> object. The driver uses the
1359:             * <code>Calendar</code> object to construct an SQL <code>DATE</code>
1360:             * value, which the driver then sends to the database. With a
1361:             * <code>Calendar</code> object, the driver can calculate the date
1362:             * taking into account a custom timezone. If no <code>Calendar</code>
1363:             * object is specified, the driver uses the default timezone, which is
1364:             * that of the virtual machine running the application.
1365:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1366:             * is automatically closed and an ongoing transaction will be
1367:             * automatically rolled back if it belongs to the executing thread.
1368:             *
1369:             * @param parameterIndex the first parameter is 1, the second is 2,
1370:             * ...
1371:             * @param x the parameter value
1372:             * @param cal the <code>Calendar</code> object the driver will use to
1373:             * construct the date
1374:             * @return this <code>DbPreparedStatement</code> instance.
1375:             * @exception DatabaseException if a database access error occurs
1376:             * @see #setDate(String, Date, Calendar)
1377:             * @see #setDates(int[], Date, Calendar)
1378:             * @since 1.0
1379:             */
1380:            public DbPreparedStatement setDate(int parameterIndex, Date x,
1381:                    Calendar cal) throws DatabaseException {
1382:                // handle virtual parameters
1383:                if (mVirtualParameters != null
1384:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1385:                    int real_index = mVirtualParameters
1386:                            .getRealIndex(parameterIndex);
1387:                    if (-1 == real_index) {
1388:                        throw new UnsupportedVirtualParameterTypeException(
1389:                                this , parameterIndex, x.getClass().getName()
1390:                                        + " with " + cal.getClass().getName());
1391:                    } else {
1392:                        parameterIndex = real_index;
1393:                    }
1394:                }
1395:
1396:                // set the real parameter
1397:                try {
1398:                    ((PreparedStatement) mStatement).setDate(parameterIndex, x,
1399:                            cal);
1400:                } catch (SQLException e) {
1401:                    handleException();
1402:                    throw new DatabaseException(e);
1403:                }
1404:
1405:                return this ;
1406:            }
1407:
1408:            /**
1409:             * Sets the named parameter to the given Java <code>int</code> value.
1410:             * The driver converts this to a SQL <code>INTEGER</code> value when
1411:             * it sends it to the database.
1412:             * <p>If a database access error occurs, this
1413:             * <code>DbPreparedStatement</code> instance is automatically closed.
1414:             *
1415:             * @param parameterName the name of the parameters that have to be set
1416:             * @param x the parameter value
1417:             * @return this <code>DbPreparedStatement</code> instance.
1418:             * @exception DatabaseException when this
1419:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1420:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1421:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1422:             * or if no parameters with this name could be found, or if a database
1423:             * access error occurs.
1424:             * @see #setInt(int, int)
1425:             * @see #setInts(int[], int)
1426:             * @since 1.0
1427:             */
1428:            public DbPreparedStatement setInt(String parameterName, int x)
1429:                    throws DatabaseException {
1430:                setInts(getParameterIndices(parameterName), x);
1431:
1432:                return this ;
1433:            }
1434:
1435:            /**
1436:             * Sets the designated parameters to the given Java <code>int</code>
1437:             * value. The driver converts this to a SQL <code>INTEGER</code> value
1438:             * when it sends it to the database.
1439:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1440:             * is automatically closed and an ongoing transaction will be
1441:             * automatically rolled back if it belongs to the executing thread.
1442:             *
1443:             * @param parameterIndices the first parameter is 1, the second is 2,
1444:             * ...
1445:             * @param x the parameter value
1446:             * @return this <code>DbPreparedStatement</code> instance.
1447:             * @exception DatabaseException if a database access error occurs
1448:             * @see #setInt(String, int)
1449:             * @see #setInt(int, int)
1450:             * @since 1.0
1451:             */
1452:            public DbPreparedStatement setInts(int[] parameterIndices, int x)
1453:                    throws DatabaseException {
1454:                if (null == parameterIndices)
1455:                    throw new IllegalArgumentException(
1456:                            "parameterIndices can't be null.");
1457:
1458:                for (int parameter_index : parameterIndices) {
1459:                    setInt(parameter_index, x);
1460:                }
1461:
1462:                return this ;
1463:            }
1464:
1465:            /**
1466:             * Sets the designated parameter to the given Java <code>int</code>
1467:             * value. The driver converts this to a SQL <code>INTEGER</code> value
1468:             * when it sends it to the database.
1469:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1470:             * is automatically closed and an ongoing transaction will be
1471:             * automatically rolled back if it belongs to the executing thread.
1472:             *
1473:             * @param parameterIndex the first parameter is 1, the second is 2,
1474:             * ...
1475:             * @param x the parameter value
1476:             * @return this <code>DbPreparedStatement</code> instance.
1477:             * @exception DatabaseException if a database access error occurs
1478:             * @see #setInt(String, int)
1479:             * @see #setInts(int[], int)
1480:             * @since 1.0
1481:             */
1482:            public DbPreparedStatement setInt(int parameterIndex, int x)
1483:                    throws DatabaseException {
1484:                // handle virtual parameters
1485:                if (mVirtualParameters != null
1486:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1487:                    int real_index = mVirtualParameters
1488:                            .getRealIndex(parameterIndex);
1489:                    if (-1 == real_index) {
1490:                        mVirtualParameters.putValue(parameterIndex, x);
1491:                        return this ;
1492:                    } else {
1493:                        parameterIndex = real_index;
1494:                    }
1495:                }
1496:
1497:                // set the real parameter
1498:                try {
1499:                    ((PreparedStatement) mStatement).setInt(parameterIndex, x);
1500:                } catch (SQLException e) {
1501:                    handleException();
1502:                    throw new DatabaseException(e);
1503:                }
1504:
1505:                return this ;
1506:            }
1507:
1508:            /**
1509:             * Sets the named parameters to the given Java <code>long</code>
1510:             * value. The driver converts this to a SQL <code>BIGINT</code> value
1511:             * when it sends it to the database.
1512:             * <p>If a database access error occurs, this
1513:             * <code>DbPreparedStatement</code> instance is automatically closed.
1514:             *
1515:             * @param parameterName the name of the parameters that have to be set
1516:             * @param x the parameter value
1517:             * @return this <code>DbPreparedStatement</code> instance.
1518:             * @exception DatabaseException when this
1519:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1520:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1521:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1522:             * or if no parameters with this name could be found, or if a database
1523:             * access error occurs.
1524:             * @see #setLongs(int[], long)
1525:             * @see #setLong(int, long)
1526:             * @since 1.0
1527:             */
1528:            public DbPreparedStatement setLong(String parameterName, long x)
1529:                    throws DatabaseException {
1530:                setLongs(getParameterIndices(parameterName), x);
1531:
1532:                return this ;
1533:            }
1534:
1535:            /**
1536:             * Sets the designated parameters to the given Java <code>long</code>
1537:             * value. The driver converts this to a SQL <code>BIGINT</code> value
1538:             * when it sends it to the database.
1539:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1540:             * is automatically closed and an ongoing transaction will be
1541:             * automatically rolled back if it belongs to the executing thread.
1542:             *
1543:             * @param parameterIndices the first parameter is 1, the second is 2,
1544:             * ...
1545:             * @param x the parameter value
1546:             * @return this <code>DbPreparedStatement</code> instance.
1547:             * @exception DatabaseException if a database access error occurs
1548:             * @see #setLong(String, long)
1549:             * @see #setLong(int, long)
1550:             * @since 1.0
1551:             */
1552:            public DbPreparedStatement setLongs(int[] parameterIndices, long x)
1553:                    throws DatabaseException {
1554:                if (null == parameterIndices)
1555:                    throw new IllegalArgumentException(
1556:                            "parameterIndices can't be null.");
1557:
1558:                for (int parameter_index : parameterIndices) {
1559:                    setLong(parameter_index, x);
1560:                }
1561:
1562:                return this ;
1563:            }
1564:
1565:            /**
1566:             * Sets the designated parameter to the given Java <code>long</code>
1567:             * value. The driver converts this to a SQL <code>BIGINT</code> value
1568:             * when it sends it to the database.
1569:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1570:             * is automatically closed and an ongoing transaction will be
1571:             * automatically rolled back if it belongs to the executing thread.
1572:             *
1573:             * @param parameterIndex the first parameter is 1, the second is 2,
1574:             * ...
1575:             * @param x the parameter value
1576:             * @return this <code>DbPreparedStatement</code> instance.
1577:             * @exception DatabaseException if a database access error occurs
1578:             * @see #setLong(String, long)
1579:             * @see #setLongs(int[], long)
1580:             * @since 1.0
1581:             */
1582:            public DbPreparedStatement setLong(int parameterIndex, long x)
1583:                    throws DatabaseException {
1584:                // handle virtual parameters
1585:                if (mVirtualParameters != null
1586:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1587:                    int real_index = mVirtualParameters
1588:                            .getRealIndex(parameterIndex);
1589:                    if (-1 == real_index) {
1590:                        mVirtualParameters.putValue(parameterIndex, x);
1591:                        return this ;
1592:                    } else {
1593:                        parameterIndex = real_index;
1594:                    }
1595:                }
1596:
1597:                // set the real parameter
1598:                try {
1599:                    ((PreparedStatement) mStatement).setLong(parameterIndex, x);
1600:                } catch (SQLException e) {
1601:                    handleException();
1602:                    throw new DatabaseException(e);
1603:                }
1604:
1605:                return this ;
1606:            }
1607:
1608:            /**
1609:             * Sets the named parameters to the given Java <code>float</code>
1610:             * value. The driver converts this to a SQL <code>FLOAT</code> value
1611:             * when it sends it to the database.
1612:             * <p>If a database access error occurs, this
1613:             * <code>DbPreparedStatement</code> instance is automatically closed.
1614:             *
1615:             * @param parameterName the name of the parameters that have to be set
1616:             * @param x the parameter value
1617:             * @return this <code>DbPreparedStatement</code> instance.
1618:             * @exception DatabaseException when this
1619:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1620:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1621:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1622:             * or if no parameters with this name could be found, or if a database
1623:             * access error occurs.
1624:             * @see #setFloats(int[], float)
1625:             * @see #setFloat(int, float)
1626:             * @since 1.0
1627:             */
1628:            public DbPreparedStatement setFloat(String parameterName, float x)
1629:                    throws DatabaseException {
1630:                setFloats(getParameterIndices(parameterName), x);
1631:
1632:                return this ;
1633:            }
1634:
1635:            /**
1636:             * Sets the designated parameters to the given Java <code>float</code>
1637:             * value. The driver converts this to a SQL <code>FLOAT</code> value
1638:             * when it sends it to the database.
1639:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1640:             * is automatically closed and an ongoing transaction will be
1641:             * automatically rolled back if it belongs to the executing thread.
1642:             *
1643:             * @param parameterIndices the first parameter is 1, the second is 2,
1644:             * ...
1645:             * @param x the parameter value
1646:             * @return this <code>DbPreparedStatement</code> instance.
1647:             * @exception DatabaseException if a database access error occurs
1648:             * @see #setFloat(String, float)
1649:             * @see #setFloat(int, float)
1650:             * @since 1.0
1651:             */
1652:            public DbPreparedStatement setFloats(int[] parameterIndices, float x)
1653:                    throws DatabaseException {
1654:                if (null == parameterIndices)
1655:                    throw new IllegalArgumentException(
1656:                            "parameterIndices can't be null.");
1657:
1658:                for (int parameter_index : parameterIndices) {
1659:                    setFloat(parameter_index, x);
1660:                }
1661:
1662:                return this ;
1663:            }
1664:
1665:            /**
1666:             * Sets the designated parameter to the given Java <code>float</code>
1667:             * value. The driver converts this to a SQL <code>FLOAT</code> value
1668:             * when it sends it to the database.
1669:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1670:             * is automatically closed and an ongoing transaction will be
1671:             * automatically rolled back if it belongs to the executing thread.
1672:             *
1673:             * @param parameterIndex the first parameter is 1, the second is 2,
1674:             * ...
1675:             * @param x the parameter value
1676:             * @return this <code>DbPreparedStatement</code> instance.
1677:             * @exception DatabaseException if a database access error occurs
1678:             * @see #setFloat(String, float)
1679:             * @see #setFloats(int[], float)
1680:             * @since 1.0
1681:             */
1682:            public DbPreparedStatement setFloat(int parameterIndex, float x)
1683:                    throws DatabaseException {
1684:                // handle virtual parameters
1685:                if (mVirtualParameters != null
1686:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1687:                    int real_index = mVirtualParameters
1688:                            .getRealIndex(parameterIndex);
1689:                    if (-1 == real_index) {
1690:                        mVirtualParameters.putValue(parameterIndex, x);
1691:                        return this ;
1692:                    } else {
1693:                        parameterIndex = real_index;
1694:                    }
1695:                }
1696:
1697:                // set the real parameter
1698:                try {
1699:                    ((PreparedStatement) mStatement)
1700:                            .setFloat(parameterIndex, x);
1701:                } catch (SQLException e) {
1702:                    handleException();
1703:                    throw new DatabaseException(e);
1704:                }
1705:
1706:                return this ;
1707:            }
1708:
1709:            /**
1710:             * Sets the named parameters to the given
1711:             * <code>java.math.BigDecimal</code> value. The driver converts this
1712:             * to a SQL <code>NUMERIC</code> value when it sends it to the
1713:             * database.
1714:             * <p>If a database access error occurs, this
1715:             * <code>DbPreparedStatement</code> instance is automatically closed.
1716:             *
1717:             * @param parameterName the name of the parameters that have to be set
1718:             * @param x the parameter value
1719:             * @return this <code>DbPreparedStatement</code> instance.
1720:             * @exception DatabaseException when this
1721:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1722:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1723:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1724:             * or if no parameters with this name could be found, or if a database
1725:             * access error occurs.
1726:             * @see #setBigDecimal(int, BigDecimal)
1727:             * @see #setBigDecimals(int[], BigDecimal)
1728:             * @since 1.0
1729:             */
1730:            public DbPreparedStatement setBigDecimal(String parameterName,
1731:                    BigDecimal x) throws DatabaseException {
1732:                setBigDecimals(getParameterIndices(parameterName), x);
1733:
1734:                return this ;
1735:            }
1736:
1737:            /**
1738:             * Sets the designated parameters to the given
1739:             * <code>java.math.BigDecimal</code> value. The driver converts this
1740:             * to a SQL <code>NUMERIC</code> value when it sends it to the
1741:             * database.
1742:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1743:             * is automatically closed and an ongoing transaction will be
1744:             * automatically rolled back if it belongs to the executing thread.
1745:             *
1746:             * @param parameterIndices the first parameter is 1, the second is 2,
1747:             * ...
1748:             * @param x the parameter value
1749:             * @return this <code>DbPreparedStatement</code> instance.
1750:             * @exception DatabaseException if a database access error occurs
1751:             * @see #setBigDecimal(String, BigDecimal)
1752:             * @see #setBigDecimal(int, BigDecimal)
1753:             * @since 1.0
1754:             */
1755:            public DbPreparedStatement setBigDecimals(int[] parameterIndices,
1756:                    BigDecimal x) throws DatabaseException {
1757:                if (null == parameterIndices)
1758:                    throw new IllegalArgumentException(
1759:                            "parameterIndices can't be null.");
1760:
1761:                for (int parameter_index : parameterIndices) {
1762:                    setBigDecimal(parameter_index, x);
1763:                }
1764:
1765:                return this ;
1766:            }
1767:
1768:            /**
1769:             * Sets the designated parameter to the given
1770:             * <code>java.math.BigDecimal</code> value. The driver converts this
1771:             * to a SQL <code>NUMERIC</code> value when it sends it to the
1772:             * database.
1773:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1774:             * is automatically closed and an ongoing transaction will be
1775:             * automatically rolled back if it belongs to the executing thread.
1776:             *
1777:             * @param parameterIndex the first parameter is 1, the second is 2,
1778:             * ...
1779:             * @param x the parameter value
1780:             * @return this <code>DbPreparedStatement</code> instance.
1781:             * @exception DatabaseException if a database access error occurs
1782:             * @see #setBigDecimal(String, BigDecimal)
1783:             * @see #setBigDecimals(int[], BigDecimal)
1784:             * @since 1.0
1785:             */
1786:            public DbPreparedStatement setBigDecimal(int parameterIndex,
1787:                    BigDecimal x) throws DatabaseException {
1788:                // handle virtual parameters
1789:                if (mVirtualParameters != null
1790:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1791:                    int real_index = mVirtualParameters
1792:                            .getRealIndex(parameterIndex);
1793:                    if (-1 == real_index) {
1794:                        mVirtualParameters.putValue(parameterIndex, x);
1795:                        return this ;
1796:                    } else {
1797:                        parameterIndex = real_index;
1798:                    }
1799:                }
1800:
1801:                // set the real parameter
1802:                try {
1803:                    ((PreparedStatement) mStatement).setBigDecimal(
1804:                            parameterIndex, x);
1805:                } catch (SQLException e) {
1806:                    handleException();
1807:                    throw new DatabaseException(e);
1808:                }
1809:
1810:                return this ;
1811:            }
1812:
1813:            /**
1814:             * Sets the named parameters to the given Java <code>String</code>
1815:             * value. The driver converts this to a SQL <code>VARCHAR</code> or
1816:             * <code>LONGVARCHAR</code> value (depending on the argument's size
1817:             * relative to the driver's limits on <code>VARCHAR</code> values)
1818:             * when it sends it to the database.
1819:             * <p>If a database access error occurs, this
1820:             * <code>DbPreparedStatement</code> instance is automatically closed.
1821:             *
1822:             * @param parameterName the name of the parameters that have to be set
1823:             * @param x the parameter value
1824:             * @return this <code>DbPreparedStatement</code> instance.
1825:             * @exception DatabaseException when this
1826:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1827:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1828:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1829:             * or if no parameters with this name could be found, or if a database
1830:             * access error occurs.
1831:             * @see #setString(int, String)
1832:             * @see #setStrings(int[], String)
1833:             * @since 1.0
1834:             */
1835:            public DbPreparedStatement setString(String parameterName, String x)
1836:                    throws DatabaseException {
1837:                setStrings(getParameterIndices(parameterName), x);
1838:
1839:                return this ;
1840:            }
1841:
1842:            /**
1843:             * Sets the designated parameters to the given Java
1844:             * <code>String</code> value. The driver converts this to a SQL
1845:             * <code>VARCHAR</code> or <code>LONGVARCHAR</code> value (depending
1846:             * on the argument's size relative to the driver's limits on
1847:             * <code>VARCHAR</code> values) when it sends it to the database.
1848:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1849:             * is automatically closed and an ongoing transaction will be
1850:             * automatically rolled back if it belongs to the executing thread.
1851:             *
1852:             * @param parameterIndices the first parameter is 1, the second is 2,
1853:             * ...
1854:             * @param x the parameter value
1855:             * @return this <code>DbPreparedStatement</code> instance.
1856:             * @exception DatabaseException if a database access error occurs
1857:             * @see #setString(String, String)
1858:             * @see #setString(int, String)
1859:             * @since 1.0
1860:             */
1861:            public DbPreparedStatement setStrings(int[] parameterIndices,
1862:                    String x) throws DatabaseException {
1863:                if (null == parameterIndices)
1864:                    throw new IllegalArgumentException(
1865:                            "parameterIndices can't be null.");
1866:
1867:                for (int parameter_index : parameterIndices) {
1868:                    setString(parameter_index, x);
1869:                }
1870:
1871:                return this ;
1872:            }
1873:
1874:            /**
1875:             * Sets the designated parameter to the given Java <code>String</code>
1876:             * value. The driver converts this to a SQL <code>VARCHAR</code> or
1877:             * <code>LONGVARCHAR</code> value (depending on the argument's size
1878:             * relative to the driver's limits on <code>VARCHAR</code> values)
1879:             * when it sends it to the database.
1880:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1881:             * is automatically closed and an ongoing transaction will be
1882:             * automatically rolled back if it belongs to the executing thread.
1883:             *
1884:             * @param parameterIndex the first parameter is 1, the second is 2,
1885:             * ...
1886:             * @param x the parameter value
1887:             * @return this <code>DbPreparedStatement</code> instance.
1888:             * @exception DatabaseException if a database access error occurs
1889:             * @see #setString(String, String)
1890:             * @see #setStrings(int[], String)
1891:             * @since 1.0
1892:             */
1893:            public DbPreparedStatement setString(int parameterIndex, String x)
1894:                    throws DatabaseException {
1895:                // handle virtual parameters
1896:                if (mVirtualParameters != null
1897:                        && mVirtualParameters.hasParameter(parameterIndex)) {
1898:                    int real_index = mVirtualParameters
1899:                            .getRealIndex(parameterIndex);
1900:                    if (-1 == real_index) {
1901:                        mVirtualParameters.putValue(parameterIndex, x);
1902:                        return this ;
1903:                    } else {
1904:                        parameterIndex = real_index;
1905:                    }
1906:                }
1907:
1908:                // set the real parameter
1909:                try {
1910:                    ((PreparedStatement) mStatement).setString(parameterIndex,
1911:                            x);
1912:                } catch (SQLException e) {
1913:                    handleException();
1914:                    throw new DatabaseException(e);
1915:                }
1916:
1917:                return this ;
1918:            }
1919:
1920:            /**
1921:             * Sets the named parameters to the given Java array of bytes. The
1922:             * driver converts this to a SQL <code>VARBINARY</code> or
1923:             * <code>LONGVARBINARY</code> (depending on the argument's size
1924:             * relative to the driver's limits on <code>VARBINARY</code> values)
1925:             * when it sends it to the database.
1926:             * <p>If a database access error occurs, this
1927:             * <code>DbPreparedStatement</code> instance is automatically closed.
1928:             *
1929:             * @param parameterName the name of the parameters that have to be set
1930:             * @param x the parameter value
1931:             * @return this <code>DbPreparedStatement</code> instance.
1932:             * @exception DatabaseException when this
1933:             * <code>DbPrepareStatement</code> instance wasn't defined by a
1934:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
1935:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
1936:             * or if no parameters with this name could be found, or if a database
1937:             * access error occurs.
1938:             * @see #setBytes(int[], byte[])
1939:             * @see #setBytes(int, byte[])
1940:             * @since 1.0
1941:             */
1942:            public DbPreparedStatement setBytes(String parameterName, byte x[])
1943:                    throws DatabaseException {
1944:                setBytes(getParameterIndices(parameterName), x);
1945:
1946:                return this ;
1947:            }
1948:
1949:            /**
1950:             * Sets the designated parameters to the given Java array of bytes.
1951:             * The driver converts this to a SQL <code>VARBINARY</code> or
1952:             * <code>LONGVARBINARY</code> (depending on the argument's size
1953:             * relative to the driver's limits on <code>VARBINARY</code> values)
1954:             * when it sends it to the database.
1955:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1956:             * is automatically closed and an ongoing transaction will be
1957:             * automatically rolled back if it belongs to the executing thread.
1958:             *
1959:             * @param parameterIndices the first parameter is 1, the second is 2,
1960:             * ...
1961:             * @param x the parameter value
1962:             * @return this <code>DbPreparedStatement</code> instance.
1963:             * @exception DatabaseException if a database access error occurs
1964:             * @see #setBytes(String, byte[])
1965:             * @see #setBytes(int, byte[])
1966:             * @since 1.0
1967:             */
1968:            public DbPreparedStatement setBytes(int[] parameterIndices,
1969:                    byte x[]) throws DatabaseException {
1970:                if (null == parameterIndices)
1971:                    throw new IllegalArgumentException(
1972:                            "parameterIndices can't be null.");
1973:
1974:                for (int parameter_index : parameterIndices) {
1975:                    setBytes(parameter_index, x);
1976:                }
1977:
1978:                return this ;
1979:            }
1980:
1981:            /**
1982:             * Sets the designated parameter to the given Java array of bytes. The
1983:             * driver converts this to a SQL <code>VARBINARY</code> or
1984:             * <code>LONGVARBINARY</code> (depending on the argument's size
1985:             * relative to the driver's limits on <code>VARBINARY</code> values)
1986:             * when it sends it to the database.
1987:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
1988:             * is automatically closed and an ongoing transaction will be
1989:             * automatically rolled back if it belongs to the executing thread.
1990:             *
1991:             * @param parameterIndex the first parameter is 1, the second is 2,
1992:             * ...
1993:             * @param x the parameter value
1994:             * @return this <code>DbPreparedStatement</code> instance.
1995:             * @exception DatabaseException if a database access error occurs
1996:             * @see #setBytes(String, byte[])
1997:             * @see #setBytes(int[], byte[])
1998:             * @since 1.0
1999:             */
2000:            public DbPreparedStatement setBytes(int parameterIndex, byte x[])
2001:                    throws DatabaseException {
2002:                // handle virtual parameters
2003:                if (mVirtualParameters != null
2004:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2005:                    int real_index = mVirtualParameters
2006:                            .getRealIndex(parameterIndex);
2007:                    if (-1 == real_index) {
2008:                        mVirtualParameters.putValue(parameterIndex, x);
2009:                        return this ;
2010:                    } else {
2011:                        parameterIndex = real_index;
2012:                    }
2013:                }
2014:
2015:                // set the real parameter
2016:                try {
2017:                    ((PreparedStatement) mStatement)
2018:                            .setBytes(parameterIndex, x);
2019:                } catch (SQLException e) {
2020:                    handleException();
2021:                    throw new DatabaseException(e);
2022:                }
2023:
2024:                return this ;
2025:            }
2026:
2027:            /**
2028:             * Sets the value of the named parameters with the given object. The
2029:             * second argument must be an object type; for integral values, the
2030:             * <code>java.lang</code> equivalent objects should be used.
2031:             * <p>The given Java object will be converted to the given
2032:             * targetSqlType before being sent to the database.
2033:             * <p>If the object has a custom mapping (is of a class implementing
2034:             * the interface <code>SQLData</code>), the JDBC driver should call
2035:             * the method <code>SQLData.writeSQL</code> to write it to the SQL
2036:             * data stream. If, on the other hand, the object is of a class
2037:             * implementing <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
2038:             * <code>Struct</code>, or <code>Array</code>, the driver should pass
2039:             * it to the database as a value of the corresponding SQL type.
2040:             * <p>If a database access error occurs, this
2041:             * <code>DbPreparedStatement</code> instance is automatically closed.
2042:             * <p>Note that this method may be used to pass database-specific
2043:             * abstract data types.
2044:             *
2045:             * @param parameterName the name of the parameters that have to be set
2046:             * @param x the object containing the input parameter value
2047:             * @param targetSqlType the SQL type (as defined in java.sql.Types) to
2048:             * be sent to the database. The scale argument may further qualify
2049:             * this type.
2050:             * @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC
2051:             * types, this is the number of digits after the decimal point. For
2052:             * all other types, this value will be ignored.
2053:             * @return this <code>DbPreparedStatement</code> instance.
2054:             * @exception DatabaseException when this
2055:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2056:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2057:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2058:             * or if no parameters with this name could be found, or if a database
2059:             * access error occurs.
2060:             * @see java.sql.Types
2061:             * @see #setObjects(int[], Object, int, int)
2062:             * @see #setObject(int, Object, int, int)
2063:             * @since 1.0
2064:             */
2065:            public DbPreparedStatement setObject(String parameterName,
2066:                    Object x, int targetSqlType, int scale)
2067:                    throws DatabaseException {
2068:                setObjects(getParameterIndices(parameterName), x,
2069:                        targetSqlType, scale);
2070:
2071:                return this ;
2072:            }
2073:
2074:            /**
2075:             * Sets the value of the designated parameters with the given object.
2076:             * The second argument must be an object type; for integral values,
2077:             * the <code>java.lang</code> equivalent objects should be used.
2078:             * <p>The given Java object will be converted to the given
2079:             * targetSqlType before being sent to the database.
2080:             * <p>If the object has a custom mapping (is of a class implementing
2081:             * the interface <code>SQLData</code>), the JDBC driver should call
2082:             * the method <code>SQLData.writeSQL</code> to write it to the SQL
2083:             * data stream. If, on the other hand, the object is of a class
2084:             * implementing <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
2085:             * <code>Struct</code>, or <code>Array</code>, the driver should pass
2086:             * it to the database as a value of the corresponding SQL type.
2087:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2088:             * is automatically closed and an ongoing transaction will be
2089:             * automatically rolled back if it belongs to the executing thread.
2090:             * <p>Note that this method may be used to pass database-specific
2091:             * abstract data types.
2092:             *
2093:             * @param parameterIndices the first parameter is 1, the second is 2,
2094:             * ...
2095:             * @param x the object containing the input parameter value
2096:             * @param targetSqlType the SQL type (as defined in java.sql.Types) to
2097:             * be sent to the database. The scale argument may further qualify
2098:             * this type.
2099:             * @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC
2100:             * types, this is the number of digits after the decimal point. For
2101:             * all other types, this value will be ignored.
2102:             * @return this <code>DbPreparedStatement</code> instance.
2103:             * @exception DatabaseException if a database access error occurs
2104:             * @see java.sql.Types
2105:             * @see #setObject(String, Object, int, int)
2106:             * @see #setObject(int, Object, int, int)
2107:             * @since 1.0
2108:             */
2109:            public DbPreparedStatement setObjects(int[] parameterIndices,
2110:                    Object x, int targetSqlType, int scale)
2111:                    throws DatabaseException {
2112:                if (null == parameterIndices)
2113:                    throw new IllegalArgumentException(
2114:                            "parameterIndices can't be null.");
2115:
2116:                for (int parameter_index : parameterIndices) {
2117:                    setObject(parameter_index, x, targetSqlType, scale);
2118:                }
2119:
2120:                return this ;
2121:            }
2122:
2123:            /**
2124:             * Sets the value of the designated parameter with the given object.
2125:             * The second argument must be an object type; for integral values,
2126:             * the <code>java.lang</code> equivalent objects should be used.
2127:             * <p>The given Java object will be converted to the given
2128:             * targetSqlType before being sent to the database.
2129:             * <p>If the object has a custom mapping (is of a class implementing
2130:             * the interface <code>SQLData</code>), the JDBC driver should call
2131:             * the method <code>SQLData.writeSQL</code> to write it to the SQL
2132:             * data stream. If, on the other hand, the object is of a class
2133:             * implementing <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
2134:             * <code>Struct</code>, or <code>Array</code>, the driver should pass
2135:             * it to the database as a value of the corresponding SQL type.
2136:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2137:             * is automatically closed and an ongoing transaction will be
2138:             * automatically rolled back if it belongs to the executing thread.
2139:             * <p>Note that this method may be used to pass database-specific
2140:             * abstract data types.
2141:             *
2142:             * @param parameterIndex the first parameter is 1, the second is 2,
2143:             * ...
2144:             * @param x the object containing the input parameter value
2145:             * @param targetSqlType the SQL type (as defined in java.sql.Types) to
2146:             * be sent to the database. The scale argument may further qualify
2147:             * this type.
2148:             * @param scale for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC
2149:             * types, this is the number of digits after the decimal point. For
2150:             * all other types, this value will be ignored.
2151:             * @return this <code>DbPreparedStatement</code> instance.
2152:             * @exception DatabaseException if a database access error occurs
2153:             * @see java.sql.Types
2154:             * @see #setObject(String, Object, int, int)
2155:             * @see #setObjects(int[], Object, int, int)
2156:             * @since 1.0
2157:             */
2158:            public DbPreparedStatement setObject(int parameterIndex, Object x,
2159:                    int targetSqlType, int scale) throws DatabaseException {
2160:                // handle virtual parameters
2161:                if (mVirtualParameters != null
2162:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2163:                    int real_index = mVirtualParameters
2164:                            .getRealIndex(parameterIndex);
2165:                    if (-1 == real_index) {
2166:                        throw new UnsupportedVirtualParameterTypeException(
2167:                                this , parameterIndex, x.getClass().getName()
2168:                                        + " targetSqlType:" + targetSqlType
2169:                                        + " scale:" + scale);
2170:                    } else {
2171:                        parameterIndex = real_index;
2172:                    }
2173:                }
2174:
2175:                // set the real parameter
2176:                try {
2177:                    ((PreparedStatement) mStatement).setObject(parameterIndex,
2178:                            x, targetSqlType, scale);
2179:                } catch (SQLException e) {
2180:                    handleException();
2181:                    throw new DatabaseException(e);
2182:                }
2183:
2184:                return this ;
2185:            }
2186:
2187:            /**
2188:             * Sets the value of the named parameters with the given object. This
2189:             * method is like the method <code>setObject</code> above, except that
2190:             * it assumes a scale of zero.
2191:             * <p>If a database access error occurs, this
2192:             * <code>DbPreparedStatement</code> instance is automatically closed.
2193:             *
2194:             * @param parameterName the name of the parameters that have to be set
2195:             * @param x the object containing the input parameter value
2196:             * @param targetSqlType the SQL type (as defined in java.sql.Types) to
2197:             * be sent to the database
2198:             * @return this <code>DbPreparedStatement</code> instance.
2199:             * @exception DatabaseException when this
2200:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2201:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2202:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2203:             * or if no parameters with this name could be found, or if a database
2204:             * access error occurs.
2205:             * @see java.sql.Types
2206:             * @see #setObjects(int[], Object, int)
2207:             * @see #setObject(int, Object, int)
2208:             * @since 1.0
2209:             */
2210:            public DbPreparedStatement setObject(String parameterName,
2211:                    Object x, int targetSqlType) throws DatabaseException {
2212:                setObjects(getParameterIndices(parameterName), x, targetSqlType);
2213:
2214:                return this ;
2215:            }
2216:
2217:            /**
2218:             * Sets the value of the designated parameters with the given object.
2219:             * This method is like the method <code>setObject</code> above, except
2220:             * that it assumes a scale of zero.
2221:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2222:             * is automatically closed and an ongoing transaction will be
2223:             * automatically rolled back if it belongs to the executing thread.
2224:             *
2225:             * @param parameterIndices the first parameter is 1, the second is 2,
2226:             * ...
2227:             * @param x the object containing the input parameter value
2228:             * @param targetSqlType the SQL type (as defined in java.sql.Types) to
2229:             * be sent to the database
2230:             * @return this <code>DbPreparedStatement</code> instance.
2231:             * @exception DatabaseException if a database access error occurs
2232:             * @see java.sql.Types
2233:             * @see #setObject(String, Object, int)
2234:             * @see #setObject(int, Object, int)
2235:             * @since 1.0
2236:             */
2237:            public DbPreparedStatement setObjects(int[] parameterIndices,
2238:                    Object x, int targetSqlType) throws DatabaseException {
2239:                if (null == parameterIndices)
2240:                    throw new IllegalArgumentException(
2241:                            "parameterIndices can't be null.");
2242:
2243:                for (int parameter_index : parameterIndices) {
2244:                    setObject(parameter_index, x, targetSqlType);
2245:                }
2246:
2247:                return this ;
2248:            }
2249:
2250:            /**
2251:             * Sets the value of the designated parameter with the given object.
2252:             * This method is like the method <code>setObject</code> above, except
2253:             * that it assumes a scale of zero.
2254:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2255:             * is automatically closed and an ongoing transaction will be
2256:             * automatically rolled back if it belongs to the executing thread.
2257:             *
2258:             * @param parameterIndex the first parameter is 1, the second is 2,
2259:             * ...
2260:             * @param x the object containing the input parameter value
2261:             * @param targetSqlType the SQL type (as defined in java.sql.Types) to
2262:             * be sent to the database
2263:             * @return this <code>DbPreparedStatement</code> instance.
2264:             * @exception DatabaseException if a database access error occurs
2265:             * @see java.sql.Types
2266:             * @see #setObject(String, Object, int)
2267:             * @see #setObjects(int[], Object, int)
2268:             * @since 1.0
2269:             */
2270:            public DbPreparedStatement setObject(int parameterIndex, Object x,
2271:                    int targetSqlType) throws DatabaseException {
2272:                // handle virtual parameters
2273:                if (mVirtualParameters != null
2274:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2275:                    int real_index = mVirtualParameters
2276:                            .getRealIndex(parameterIndex);
2277:                    if (-1 == real_index) {
2278:                        throw new UnsupportedVirtualParameterTypeException(
2279:                                this , parameterIndex, x.getClass().getName()
2280:                                        + " targetSqlType:" + targetSqlType);
2281:                    } else {
2282:                        parameterIndex = real_index;
2283:                    }
2284:                }
2285:
2286:                try {
2287:                    ((PreparedStatement) mStatement).setObject(parameterIndex,
2288:                            x, targetSqlType);
2289:                } catch (SQLException e) {
2290:                    handleException();
2291:                    throw new DatabaseException(e);
2292:                }
2293:
2294:                return this ;
2295:            }
2296:
2297:            /**
2298:             * Sets the named parameters to the given <code>java.sql.Time</code>
2299:             * value. The driver converts this to a SQL <code>TIME</code> value
2300:             * when it sends it to the database.
2301:             * <p>If a database access error occurs, this
2302:             * <code>DbPreparedStatement</code> instance is automatically closed.
2303:             *
2304:             * @param parameterName the name of the parameters that have to be set
2305:             * @param x the parameter value
2306:             * @return this <code>DbPreparedStatement</code> instance.
2307:             * @exception DatabaseException when this
2308:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2309:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2310:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2311:             * or if no parameters with this name could be found, or if a database
2312:             * access error occurs.
2313:             * @see #setTimes(int[], Time)
2314:             * @see #setTime(int, Time)
2315:             * @since 1.0
2316:             */
2317:            public DbPreparedStatement setTime(String parameterName, Time x)
2318:                    throws DatabaseException {
2319:                setTimes(getParameterIndices(parameterName), x);
2320:
2321:                return this ;
2322:            }
2323:
2324:            /**
2325:             * Sets the designated parameters to the given
2326:             * <code>java.sql.Time</code> value. The driver converts this to a SQL
2327:             * <code>TIME</code> value when it sends it to the database.
2328:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2329:             * is automatically closed and an ongoing transaction will be
2330:             * automatically rolled back if it belongs to the executing thread.
2331:             *
2332:             * @param parameterIndices the first parameter is 1, the second is 2,
2333:             * ...
2334:             * @param x the parameter value
2335:             * @return this <code>DbPreparedStatement</code> instance.
2336:             * @exception DatabaseException if a database access error occurs
2337:             * @see #setTime(String, Time)
2338:             * @see #setTime(int, Time)
2339:             * @since 1.0
2340:             */
2341:            public DbPreparedStatement setTimes(int[] parameterIndices, Time x)
2342:                    throws DatabaseException {
2343:                if (null == parameterIndices)
2344:                    throw new IllegalArgumentException(
2345:                            "parameterIndices can't be null.");
2346:
2347:                for (int parameter_index : parameterIndices) {
2348:                    setTime(parameter_index, x);
2349:                }
2350:
2351:                return this ;
2352:            }
2353:
2354:            /**
2355:             * Sets the designated parameter to the given
2356:             * <code>java.sql.Time</code> value. The driver converts this to a SQL
2357:             * <code>TIME</code> value when it sends it to the database.
2358:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2359:             * is automatically closed and an ongoing transaction will be
2360:             * automatically rolled back if it belongs to the executing thread.
2361:             *
2362:             * @param parameterIndex the first parameter is 1, the second is 2,
2363:             * ...
2364:             * @param x the parameter value
2365:             * @return this <code>DbPreparedStatement</code> instance.
2366:             * @exception DatabaseException if a database access error occurs
2367:             * @see #setTime(String, Time)
2368:             * @see #setTimes(int[], Time)
2369:             * @since 1.0
2370:             */
2371:            public DbPreparedStatement setTime(int parameterIndex, Time x)
2372:                    throws DatabaseException {
2373:                // handle virtual parameters
2374:                if (mVirtualParameters != null
2375:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2376:                    int real_index = mVirtualParameters
2377:                            .getRealIndex(parameterIndex);
2378:                    if (-1 == real_index) {
2379:                        mVirtualParameters.putValue(parameterIndex, x);
2380:                        return this ;
2381:                    } else {
2382:                        parameterIndex = real_index;
2383:                    }
2384:                }
2385:
2386:                // set the real parameter
2387:                try {
2388:                    ((PreparedStatement) mStatement).setTime(parameterIndex, x);
2389:                } catch (SQLException e) {
2390:                    handleException();
2391:                    throw new DatabaseException(e);
2392:                }
2393:
2394:                return this ;
2395:            }
2396:
2397:            /**
2398:             * Sets the named parameters to the given <code>java.sql.Time</code>
2399:             * value, using the given <code>Calendar</code> object. The driver
2400:             * uses the <code>Calendar</code> object to construct an SQL
2401:             * <code>TIME</code> value, which the driver then sends to the
2402:             * database. With a <code>Calendar</code> object, the driver can
2403:             * calculate the time taking into account a custom timezone. If no
2404:             * <code>Calendar</code> object is specified, the driver uses the
2405:             * default timezone, which is that of the virtual machine running the
2406:             * application.
2407:             * <p>If a database access error occurs, this
2408:             * <code>DbPreparedStatement</code> instance is automatically closed.
2409:             *
2410:             * @param parameterName the name of the parameters that have to be set
2411:             * @param x the parameter value
2412:             * @param cal the <code>Calendar</code> object the driver will use to
2413:             * construct the time
2414:             * @return this <code>DbPreparedStatement</code> instance.
2415:             * @exception DatabaseException when this
2416:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2417:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2418:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2419:             * or if no parameters with this name could be found, or if a database
2420:             * access error occurs.
2421:             * @see #setTimes(int[], Time, Calendar)
2422:             * @see #setTime(int, Time, Calendar)
2423:             * @since 1.0
2424:             */
2425:            public DbPreparedStatement setTime(String parameterName, Time x,
2426:                    Calendar cal) throws DatabaseException {
2427:                setTimes(getParameterIndices(parameterName), x, cal);
2428:
2429:                return this ;
2430:            }
2431:
2432:            /**
2433:             * Sets the designated parameters to the given
2434:             * <code>java.sql.Time</code> value, using the given
2435:             * <code>Calendar</code> object. The driver uses the
2436:             * <code>Calendar</code> object to construct an SQL <code>TIME</code>
2437:             * value, which the driver then sends to the database. With a
2438:             * <code>Calendar</code> object, the driver can calculate the time
2439:             * taking into account a custom timezone. If no <code>Calendar</code>
2440:             * object is specified, the driver uses the default timezone, which is
2441:             * that of the virtual machine running the application.
2442:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2443:             * is automatically closed and an ongoing transaction will be
2444:             * automatically rolled back if it belongs to the executing thread.
2445:             *
2446:             * @param parameterIndices the first parameter is 1, the second is 2,
2447:             * ...
2448:             * @param x the parameter value
2449:             * @param cal the <code>Calendar</code> object the driver will use to
2450:             * construct the time
2451:             * @return this <code>DbPreparedStatement</code> instance.
2452:             * @exception DatabaseException if a database access error occurs
2453:             * @see #setTime(String, Time, Calendar)
2454:             * @see #setTime(int, Time, Calendar)
2455:             * @since 1.0
2456:             */
2457:            public DbPreparedStatement setTimes(int[] parameterIndices, Time x,
2458:                    Calendar cal) throws DatabaseException {
2459:                if (null == parameterIndices)
2460:                    throw new IllegalArgumentException(
2461:                            "parameterIndices can't be null.");
2462:
2463:                for (int parameter_index : parameterIndices) {
2464:                    setTime(parameter_index, x, cal);
2465:                }
2466:
2467:                return this ;
2468:            }
2469:
2470:            /**
2471:             * Sets the designated parameter to the given
2472:             * <code>java.sql.Time</code> value, using the given
2473:             * <code>Calendar</code> object. The driver uses the
2474:             * <code>Calendar</code> object to construct an SQL <code>TIME</code>
2475:             * value, which the driver then sends to the database. With a
2476:             * <code>Calendar</code> object, the driver can calculate the time
2477:             * taking into account a custom timezone. If no <code>Calendar</code>
2478:             * object is specified, the driver uses the default timezone, which is
2479:             * that of the virtual machine running the application.
2480:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2481:             * is automatically closed and an ongoing transaction will be
2482:             * automatically rolled back if it belongs to the executing thread.
2483:             *
2484:             * @param parameterIndex the first parameter is 1, the second is 2,
2485:             * ...
2486:             * @param x the parameter value
2487:             * @param cal the <code>Calendar</code> object the driver will use to
2488:             * construct the time
2489:             * @return this <code>DbPreparedStatement</code> instance.
2490:             * @exception DatabaseException if a database access error occurs
2491:             * @see #setTime(String, Time, Calendar)
2492:             * @see #setTimes(int[], Time, Calendar)
2493:             * @since 1.0
2494:             */
2495:            public DbPreparedStatement setTime(int parameterIndex, Time x,
2496:                    Calendar cal) throws DatabaseException {
2497:                // handle virtual parameters
2498:                if (mVirtualParameters != null
2499:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2500:                    int real_index = mVirtualParameters
2501:                            .getRealIndex(parameterIndex);
2502:                    if (-1 == real_index) {
2503:                        throw new UnsupportedVirtualParameterTypeException(
2504:                                this , parameterIndex, x.getClass().getName()
2505:                                        + " with " + cal.getClass().getName());
2506:                    } else {
2507:                        parameterIndex = real_index;
2508:                    }
2509:                }
2510:
2511:                // set the real parameter
2512:                try {
2513:                    ((PreparedStatement) mStatement).setTime(parameterIndex, x,
2514:                            cal);
2515:                } catch (SQLException e) {
2516:                    handleException();
2517:                    throw new DatabaseException(e);
2518:                }
2519:
2520:                return this ;
2521:            }
2522:
2523:            /**
2524:             * Sets the named parameters to the given
2525:             * <code>java.sql.Timestamp</code> value. The driver converts this to
2526:             * a SQL <code>TIMESTAMP</code> value when it sends it to the
2527:             * database.
2528:             * <p>If a database access error occurs, this
2529:             * <code>DbPreparedStatement</code> instance is automatically closed.
2530:             *
2531:             * @param parameterName the name of the parameters that have to be set
2532:             * @param x the parameter value
2533:             * @return this <code>DbPreparedStatement</code> instance.
2534:             * @exception DatabaseException when this
2535:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2536:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2537:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2538:             * or if no parameters with this name could be found, or if a database
2539:             * access error occurs.
2540:             * @see #setTimestamps(int[], Timestamp)
2541:             * @see #setTimestamp(int, Timestamp)
2542:             * @since 1.0
2543:             */
2544:            public DbPreparedStatement setTimestamp(String parameterName,
2545:                    Timestamp x) throws DatabaseException {
2546:                setTimestamps(getParameterIndices(parameterName), x);
2547:
2548:                return this ;
2549:            }
2550:
2551:            /**
2552:             * Sets the designated parameters to the given
2553:             * <code>java.sql.Timestamp</code> value. The driver converts this to
2554:             * a SQL <code>TIMESTAMP</code> value when it sends it to the
2555:             * database.
2556:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2557:             * is automatically closed and an ongoing transaction will be
2558:             * automatically rolled back if it belongs to the executing thread.
2559:             *
2560:             * @param parameterIndices the first parameter is 1, the second is 2,
2561:             * ...
2562:             * @param x the parameter value
2563:             * @return this <code>DbPreparedStatement</code> instance.
2564:             * @exception DatabaseException if a database access error occurs
2565:             * @see #setTimestamp(String, Timestamp)
2566:             * @see #setTimestamp(int, Timestamp)
2567:             * @since 1.0
2568:             */
2569:            public DbPreparedStatement setTimestamps(int[] parameterIndices,
2570:                    Timestamp x) throws DatabaseException {
2571:                if (null == parameterIndices)
2572:                    throw new IllegalArgumentException(
2573:                            "parameterIndices can't be null.");
2574:
2575:                for (int parameter_index : parameterIndices) {
2576:                    setTimestamp(parameter_index, x);
2577:                }
2578:
2579:                return this ;
2580:            }
2581:
2582:            /**
2583:             * Sets the designated parameter to the given
2584:             * <code>java.sql.Timestamp</code> value. The driver converts this to
2585:             * a SQL <code>TIMESTAMP</code> value when it sends it to the
2586:             * database.
2587:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2588:             * is automatically closed and an ongoing transaction will be
2589:             * automatically rolled back if it belongs to the executing thread.
2590:             *
2591:             * @param parameterIndex the first parameter is 1, the second is 2,
2592:             * ...
2593:             * @param x the parameter value
2594:             * @return this <code>DbPreparedStatement</code> instance.
2595:             * @exception DatabaseException if a database access error occurs
2596:             * @see #setTimestamp(String, Timestamp)
2597:             * @see #setTimestamps(int[], Timestamp)
2598:             * @since 1.0
2599:             */
2600:            public DbPreparedStatement setTimestamp(int parameterIndex,
2601:                    Timestamp x) throws DatabaseException {
2602:                // handle virtual parameters
2603:                if (mVirtualParameters != null
2604:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2605:                    int real_index = mVirtualParameters
2606:                            .getRealIndex(parameterIndex);
2607:                    if (-1 == real_index) {
2608:                        mVirtualParameters.putValue(parameterIndex, x);
2609:                        return this ;
2610:                    } else {
2611:                        parameterIndex = real_index;
2612:                    }
2613:                }
2614:
2615:                // set the real parameter
2616:                try {
2617:                    ((PreparedStatement) mStatement).setTimestamp(
2618:                            parameterIndex, x);
2619:                } catch (SQLException e) {
2620:                    handleException();
2621:                    throw new DatabaseException(e);
2622:                }
2623:
2624:                return this ;
2625:            }
2626:
2627:            /**
2628:             * Sets the named parameters to the given
2629:             * <code>java.sql.Timestamp</code> value, using the given
2630:             * <code>Calendar</code> object. The driver uses the
2631:             * <code>Calendar</code> object to construct an SQL
2632:             * <code>TIMESTAMP</code> value, which the driver then sends to the
2633:             * database. With a <code>Calendar</code> object, the driver can
2634:             * calculate the timestamp taking into account a custom timezone. If
2635:             * no <code>Calendar</code> object is specified, the driver uses the
2636:             * default timezone, which is that of the virtual machine running the
2637:             * application.
2638:             * <p>If a database access error occurs, this
2639:             * <code>DbPreparedStatement</code> instance is automatically closed.
2640:             *
2641:             * @param parameterName the name of the parameters that have to be set
2642:             * @param x the parameter value
2643:             * @param cal the <code>Calendar</code> object the driver will use to
2644:             * construct the timestamp
2645:             * @return this <code>DbPreparedStatement</code> instance.
2646:             * @exception DatabaseException when this
2647:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2648:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2649:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2650:             * or if no parameters with this name could be found, or if a database
2651:             * access error occurs.
2652:             * @see #setTimestamps(int[], Timestamp, Calendar)
2653:             * @see #setTimestamp(int, Timestamp, Calendar)
2654:             * @since 1.0
2655:             */
2656:            public DbPreparedStatement setTimestamp(String parameterName,
2657:                    Timestamp x, Calendar cal) throws DatabaseException {
2658:                setTimestamps(getParameterIndices(parameterName), x, cal);
2659:
2660:                return this ;
2661:            }
2662:
2663:            /**
2664:             * Sets the designated parameters to the given
2665:             * <code>java.sql.Timestamp</code> value, using the given
2666:             * <code>Calendar</code> object. The driver uses the
2667:             * <code>Calendar</code> object to construct an SQL
2668:             * <code>TIMESTAMP</code> value, which the driver then sends to the
2669:             * database. With a <code>Calendar</code> object, the driver can
2670:             * calculate the timestamp taking into account a custom timezone. If
2671:             * no <code>Calendar</code> object is specified, the driver uses the
2672:             * default timezone, which is that of the virtual machine running the
2673:             * application.
2674:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2675:             * is automatically closed and an ongoing transaction will be
2676:             * automatically rolled back if it belongs to the executing thread.
2677:             *
2678:             * @param parameterIndices the first parameter is 1, the second is 2,
2679:             * ...
2680:             * @param x the parameter value
2681:             * @param cal the <code>Calendar</code> object the driver will use to
2682:             * construct the timestamp
2683:             * @return this <code>DbPreparedStatement</code> instance.
2684:             * @exception DatabaseException if a database access error occurs
2685:             * @see #setTimestamp(String, Timestamp, Calendar)
2686:             * @see #setTimestamp(int, Timestamp, Calendar)
2687:             * @since 1.0
2688:             */
2689:            public DbPreparedStatement setTimestamps(int[] parameterIndices,
2690:                    Timestamp x, Calendar cal) throws DatabaseException {
2691:                if (null == parameterIndices)
2692:                    throw new IllegalArgumentException(
2693:                            "parameterIndices can't be null.");
2694:
2695:                for (int parameter_index : parameterIndices) {
2696:                    setTimestamp(parameter_index, x, cal);
2697:                }
2698:
2699:                return this ;
2700:            }
2701:
2702:            /**
2703:             * Sets the designated parameter to the given
2704:             * <code>java.sql.Timestamp</code> value, using the given
2705:             * <code>Calendar</code> object. The driver uses the
2706:             * <code>Calendar</code> object to construct an SQL
2707:             * <code>TIMESTAMP</code> value, which the driver then sends to the
2708:             * database. With a <code>Calendar</code> object, the driver can
2709:             * calculate the timestamp taking into account a custom timezone. If
2710:             * no <code>Calendar</code> object is specified, the driver uses the
2711:             * default timezone, which is that of the virtual machine running the
2712:             * application.
2713:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2714:             * is automatically closed and an ongoing transaction will be
2715:             * automatically rolled back if it belongs to the executing thread.
2716:             *
2717:             * @param parameterIndex the first parameter is 1, the second is 2,
2718:             * ...
2719:             * @param x the parameter value
2720:             * @param cal the <code>Calendar</code> object the driver will use to
2721:             * construct the timestamp
2722:             * @return this <code>DbPreparedStatement</code> instance.
2723:             * @exception DatabaseException if a database access error occurs
2724:             * @see #setTimestamp(String, Timestamp, Calendar)
2725:             * @see #setTimestamps(int[], Timestamp, Calendar)
2726:             * @since 1.0
2727:             */
2728:            public DbPreparedStatement setTimestamp(int parameterIndex,
2729:                    Timestamp x, Calendar cal) throws DatabaseException {
2730:                // handle virtual parameters
2731:                if (mVirtualParameters != null
2732:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2733:                    int real_index = mVirtualParameters
2734:                            .getRealIndex(parameterIndex);
2735:                    if (-1 == real_index) {
2736:                        throw new UnsupportedVirtualParameterTypeException(
2737:                                this , parameterIndex, x.getClass().getName()
2738:                                        + " with " + cal.getClass().getName());
2739:                    } else {
2740:                        parameterIndex = real_index;
2741:                    }
2742:                }
2743:
2744:                // set the real parameter
2745:                try {
2746:                    ((PreparedStatement) mStatement).setTimestamp(
2747:                            parameterIndex, x, cal);
2748:                } catch (SQLException e) {
2749:                    handleException();
2750:                    throw new DatabaseException(e);
2751:                }
2752:
2753:                return this ;
2754:            }
2755:
2756:            /**
2757:             * Sets the named parameter to the given input stream, which will have
2758:             * the specified number of bytes. When a very large ASCII value is
2759:             * input to a <code>LONGVARCHAR</code> parameter, it may be more
2760:             * practical to send it via a <code>java.io.InputStream</code>. Data
2761:             * will be read from the stream as needed until end-of-file is
2762:             * reached. The JDBC driver will do any necessary conversion from
2763:             * ASCII to the database char format.
2764:             * <p>If a database access error occurs, this
2765:             * <code>DbPreparedStatement</code> instance is automatically closed.
2766:             * <p><b>Note:</b> This stream object can either be a standard Java
2767:             * stream object or your own subclass that implements the standard
2768:             * interface.
2769:             *
2770:             * @param parameterName the name of the parameter that will be set
2771:             * (the first parameter with the name will be used)
2772:             * @param x the Java input stream that contains the ASCII parameter
2773:             * value
2774:             * @param length the number of bytes in the stream
2775:             * @return this <code>DbPreparedStatement</code> instance.
2776:             * @exception DatabaseException when this
2777:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2778:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2779:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2780:             * or if no parameters with this name could be found, or if a database
2781:             * access error occurs.
2782:             * @see #setAsciiStream(int, InputStream, int)
2783:             * @since 1.0
2784:             */
2785:            public DbPreparedStatement setAsciiStream(String parameterName,
2786:                    InputStream x, int length) throws DatabaseException {
2787:                setAsciiStream(getParameterIndices(parameterName)[0], x, length);
2788:
2789:                return this ;
2790:            }
2791:
2792:            /**
2793:             * Sets the designated parameter to the given input stream, which will
2794:             * have the specified number of bytes. When a very large ASCII value
2795:             * is input to a <code>LONGVARCHAR</code> parameter, it may be more
2796:             * practical to send it via a <code>java.io.InputStream</code>. Data
2797:             * will be read from the stream as needed until end-of-file is
2798:             * reached. The JDBC driver will do any necessary conversion from
2799:             * ASCII to the database char format.
2800:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2801:             * is automatically closed and an ongoing transaction will be
2802:             * automatically rolled back if it belongs to the executing thread.
2803:             * <p><b>Note:</b> This stream object can either be a standard Java
2804:             * stream object or your own subclass that implements the standard
2805:             * interface.
2806:             *
2807:             * @param parameterIndex the first parameter is 1, the second is 2,
2808:             * ...
2809:             * @param x the Java input stream that contains the ASCII parameter
2810:             * value
2811:             * @param length the number of bytes in the stream
2812:             * @return this <code>DbPreparedStatement</code> instance.
2813:             * @exception DatabaseException if a database access error occurs
2814:             * @see #setAsciiStream(String, InputStream, int)
2815:             * @since 1.0
2816:             */
2817:            public DbPreparedStatement setAsciiStream(int parameterIndex,
2818:                    InputStream x, int length) throws DatabaseException {
2819:                // handle virtual parameters
2820:                if (mVirtualParameters != null
2821:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2822:                    int real_index = mVirtualParameters
2823:                            .getRealIndex(parameterIndex);
2824:                    if (-1 == real_index) {
2825:                        throw new UnsupportedVirtualParameterTypeException(
2826:                                this , parameterIndex, x.getClass().getName()
2827:                                        + " length:" + length);
2828:                    } else {
2829:                        parameterIndex = real_index;
2830:                    }
2831:                }
2832:
2833:                // set the real parameter
2834:                try {
2835:                    ((PreparedStatement) mStatement).setAsciiStream(
2836:                            parameterIndex, x, length);
2837:                } catch (SQLException e) {
2838:                    handleException();
2839:                    throw new DatabaseException(e);
2840:                }
2841:
2842:                return this ;
2843:            }
2844:
2845:            /**
2846:             * Sets the named parameter to the given <code>Reader</code> object,
2847:             * which is the given number of characters long. When a very large
2848:             * UNICODE value is input to a <code>LONGVARCHAR</code> parameter, it
2849:             * may be more practical to send it via a <code>java.io.Reader</code>
2850:             * object. The data will be read from the stream as needed until
2851:             * end-of-file is reached. The JDBC driver will do any necessary
2852:             * conversion from UNICODE to the database char format.
2853:             * <p>If a database access error occurs, this
2854:             * <code>DbPreparedStatement</code> instance is automatically closed.
2855:             * <p><b>Note:</b> This stream object can either be a standard Java
2856:             * stream object or your own subclass that implements the standard
2857:             * interface.
2858:             *
2859:             * @param parameterName the name of the parameter that will be set
2860:             * (the first parameter with the name will be used)
2861:             * @param x the <code>java.io.Reader</code> object that contains
2862:             * the Unicode data
2863:             * @param length the number of characters in the stream
2864:             * @return this <code>DbPreparedStatement</code> instance.
2865:             * @exception DatabaseException when this
2866:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2867:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2868:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2869:             * or if no parameters with this name could be found, or if a database
2870:             * access error occurs.
2871:             * @see #setCharacterStream(int, Reader, int)
2872:             * @since 1.0
2873:             */
2874:            public DbPreparedStatement setCharacterStream(String parameterName,
2875:                    Reader x, int length) throws DatabaseException {
2876:                setCharacterStream(getParameterIndices(parameterName)[0], x,
2877:                        length);
2878:
2879:                return this ;
2880:            }
2881:
2882:            /**
2883:             * Sets the designated parameter to the given <code>Reader</code>
2884:             * object, which is the given number of characters long. When a very
2885:             * large UNICODE value is input to a <code>LONGVARCHAR</code>
2886:             * parameter, it may be more practical to send it via a
2887:             * <code>java.io.Reader</code> object. The data will be read from the
2888:             * stream as needed until end-of-file is reached. The JDBC driver will
2889:             * do any necessary conversion from UNICODE to the database char
2890:             * format.
2891:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2892:             * is automatically closed and an ongoing transaction will be
2893:             * automatically rolled back if it belongs to the executing thread.
2894:             * <p><b>Note:</b> This stream object can either be a standard Java
2895:             * stream object or your own subclass that implements the standard
2896:             * interface.
2897:             *
2898:             * @param parameterIndex the first parameter is 1, the second is 2,
2899:             * ...
2900:             * @param x the <code>java.io.Reader</code> object that contains
2901:             * the Unicode data
2902:             * @param length the number of characters in the stream
2903:             * @return this <code>DbPreparedStatement</code> instance.
2904:             * @exception DatabaseException if a database access error occurs
2905:             * @see #setCharacterStream(String, Reader, int)
2906:             * @since 1.0
2907:             */
2908:            public DbPreparedStatement setCharacterStream(int parameterIndex,
2909:                    Reader x, int length) throws DatabaseException {
2910:                // handle virtual parameters
2911:                if (mVirtualParameters != null
2912:                        && mVirtualParameters.hasParameter(parameterIndex)) {
2913:                    int real_index = mVirtualParameters
2914:                            .getRealIndex(parameterIndex);
2915:                    if (-1 == real_index) {
2916:                        throw new UnsupportedVirtualParameterTypeException(
2917:                                this , parameterIndex, x.getClass().getName()
2918:                                        + " length:" + length);
2919:                    } else {
2920:                        parameterIndex = real_index;
2921:                    }
2922:                }
2923:
2924:                // set the real parameter
2925:                try {
2926:                    ((PreparedStatement) mStatement).setCharacterStream(
2927:                            parameterIndex, x, length);
2928:                } catch (SQLException e) {
2929:                    handleException();
2930:                    throw new DatabaseException(e);
2931:                }
2932:
2933:                return this ;
2934:            }
2935:
2936:            /**
2937:             * Sets the named parameter to the given input stream, which will have
2938:             * the specified number of bytes. When a very large binary value is
2939:             * input to a <code>LONGVARBINARY</code> parameter, it may be more
2940:             * practical to send it via a <code>java.io.InputStream</code> object.
2941:             * The data will be read from the stream as needed until end-of-file
2942:             * is reached.
2943:             * <p>If a database access error occurs, this
2944:             * <code>DbPreparedStatement</code> instance is automatically closed.
2945:             * <p><b>Note:</b> This stream object can either be a standard Java
2946:             * stream object or your own subclass that implements the standard
2947:             * interface.
2948:             *
2949:             * @param parameterName the name of the parameter that will be set
2950:             * (the first parameter with the name will be used)
2951:             * @param x the java input stream which contains the binary parameter
2952:             * value
2953:             * @param length the number of bytes in the stream
2954:             * @return this <code>DbPreparedStatement</code> instance.
2955:             * @exception DatabaseException when this
2956:             * <code>DbPrepareStatement</code> instance wasn't defined by a
2957:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
2958:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
2959:             * or if no parameters with this name could be found, or if a database
2960:             * access error occurs.
2961:             * @see #setBinaryStream(int, InputStream, int)
2962:             * @since 1.0
2963:             */
2964:            public DbPreparedStatement setBinaryStream(String parameterName,
2965:                    InputStream x, int length) throws DatabaseException {
2966:                setBinaryStream(getParameterIndices(parameterName)[0], x,
2967:                        length);
2968:
2969:                return this ;
2970:            }
2971:
2972:            /**
2973:             * Sets the designated parameter to the given input stream, which will
2974:             * have the specified number of bytes. When a very large binary value
2975:             * is input to a <code>LONGVARBINARY</code> parameter, it may be more
2976:             * practical to send it via a <code>java.io.InputStream</code> object.
2977:             * The data will be read from the stream as needed until end-of-file
2978:             * is reached.
2979:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
2980:             * is automatically closed and an ongoing transaction will be
2981:             * automatically rolled back if it belongs to the executing thread.
2982:             * <p><b>Note:</b> This stream object can either be a standard Java
2983:             * stream object or your own subclass that implements the standard
2984:             * interface.
2985:             *
2986:             * @param parameterIndex the first parameter is 1, the second is 2,
2987:             * ...
2988:             * @param x the java input stream which contains the binary parameter
2989:             * value
2990:             * @param length the number of bytes in the stream
2991:             * @return this <code>DbPreparedStatement</code> instance.
2992:             * @exception DatabaseException if a database access error occurs
2993:             * @see #setBinaryStream(String, InputStream, int)
2994:             * @since 1.0
2995:             */
2996:            public DbPreparedStatement setBinaryStream(int parameterIndex,
2997:                    InputStream x, int length) throws DatabaseException {
2998:                // handle virtual parameters
2999:                if (mVirtualParameters != null
3000:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3001:                    int real_index = mVirtualParameters
3002:                            .getRealIndex(parameterIndex);
3003:                    if (-1 == real_index) {
3004:                        throw new UnsupportedVirtualParameterTypeException(
3005:                                this , parameterIndex, x.getClass().getName()
3006:                                        + " length:" + length);
3007:                    } else {
3008:                        parameterIndex = real_index;
3009:                    }
3010:                }
3011:
3012:                // set the real parameter
3013:                try {
3014:                    ((PreparedStatement) mStatement).setBinaryStream(
3015:                            parameterIndex, x, length);
3016:                } catch (SQLException e) {
3017:                    handleException();
3018:                    throw new DatabaseException(e);
3019:                }
3020:
3021:                return this ;
3022:            }
3023:
3024:            /**
3025:             * Sets the named parameters to the given <code>Array</code> object.
3026:             * The driver converts this to a SQL <code>ARRAY</code> value when it
3027:             * sends it to the database.
3028:             * <p>If a database access error occurs, this
3029:             * <code>DbPreparedStatement</code> instance is automatically closed.
3030:             *
3031:             * @param parameterName the name of the parameter that will be set
3032:             * @param x an <code>Array</code> object that maps an SQL
3033:             * <code>ARRAY</code> value
3034:             * @return this <code>DbPreparedStatement</code> instance.
3035:             * @exception DatabaseException when this
3036:             * <code>DbPrepareStatement</code> instance wasn't defined by a
3037:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
3038:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
3039:             * or if no parameters with this name could be found, or if a database
3040:             * access error occurs.
3041:             * @see #setArray(int, Array)
3042:             * @since 1.0
3043:             */
3044:            public DbPreparedStatement setArray(String parameterName, Array x)
3045:                    throws DatabaseException {
3046:                setArray(getParameterIndices(parameterName)[0], x);
3047:
3048:                return this ;
3049:            }
3050:
3051:            /**
3052:             * Sets the designated parameter to the given <code>Array</code>
3053:             * object. The driver converts this to a SQL <code>ARRAY</code> value
3054:             * when it sends it to the database.
3055:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3056:             * is automatically closed and an ongoing transaction will be
3057:             * automatically rolled back if it belongs to the executing thread.
3058:             *
3059:             * @param parameterIndex the first parameter is 1, the second is 2,
3060:             * ...
3061:             * @param x an <code>Array</code> object that maps an SQL
3062:             * <code>ARRAY</code> value
3063:             * @return this <code>DbPreparedStatement</code> instance.
3064:             * @exception DatabaseException if a database access error occurs
3065:             * @see #setArray(String, Array)
3066:             * @since 1.0
3067:             */
3068:            public DbPreparedStatement setArray(int parameterIndex, Array x)
3069:                    throws DatabaseException {
3070:                // handle virtual parameters
3071:                if (mVirtualParameters != null
3072:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3073:                    int real_index = mVirtualParameters
3074:                            .getRealIndex(parameterIndex);
3075:                    if (-1 == real_index) {
3076:                        throw new UnsupportedVirtualParameterTypeException(
3077:                                this , parameterIndex, x.getClass().getName());
3078:                    } else {
3079:                        parameterIndex = real_index;
3080:                    }
3081:                }
3082:
3083:                // set the real parameter
3084:                try {
3085:                    ((PreparedStatement) mStatement)
3086:                            .setArray(parameterIndex, x);
3087:                } catch (SQLException e) {
3088:                    handleException();
3089:                    throw new DatabaseException(e);
3090:                }
3091:
3092:                return this ;
3093:            }
3094:
3095:            /**
3096:             * Sets the value of the named parameters using the given object. The
3097:             * second parameter must be of type <code>Object</code>; therefore,
3098:             * the <code>java.lang</code> equivalent objects should be used for
3099:             * built-in types.
3100:             * <p>The JDBC specification specifies a standard mapping from Java
3101:             * <code>Object</code> types to SQL types. The given argument will be
3102:             * converted to the corresponding SQL type before being sent to the
3103:             * database.
3104:             * <p>Note that this method may be used to pass datatabase-specific
3105:             * abstract data types, by using a driver-specific Java type.
3106:             * <p>If the object is of a class implementing the interface
3107:             * <code>SQLData</code>, the JDBC driver should call the method
3108:             * <code>SQLData.writeSQL</code> to write it to the SQL data stream.
3109:             * If, on the other hand, the object is of a class implementing
3110:             * <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
3111:             * <code>Struct</code>, or <code>Array</code>, the driver should pass
3112:             * it to the database as a value of the corresponding SQL type.
3113:             * <p>This method throws an exception if there is an ambiguity, for
3114:             * example, if the object is of a class implementing more than one of
3115:             * the interfaces named above.
3116:             * <p>If such an ambiquity exception is thrown or if a database access
3117:             * error occurs, this <code>DbPreparedStatement</code> instance is
3118:             * automatically closed.
3119:             *
3120:             * @param parameterName the name of the parameter that will be set
3121:             * @param x the object containing the input parameter value
3122:             * @return this <code>DbPreparedStatement</code> instance.
3123:             * @exception DatabaseException when this
3124:             * <code>DbPrepareStatement</code> instance wasn't defined by a
3125:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
3126:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
3127:             * or if no parameters with this name could be found, or if a database
3128:             * access error occurs, or if the type of the given object is
3129:             * ambiguous.
3130:             * @see #setObjects(int[], Object)
3131:             * @see #setObject(int, Object)
3132:             * @since 1.0
3133:             */
3134:            public DbPreparedStatement setObject(String parameterName, Object x)
3135:                    throws DatabaseException {
3136:                setObjects(getParameterIndices(parameterName), x);
3137:
3138:                return this ;
3139:            }
3140:
3141:            /**
3142:             * Sets the value of the designated parameters using the given object.
3143:             * The second parameter must be of type <code>Object</code>;
3144:             * therefore, the <code>java.lang</code> equivalent objects should be
3145:             * used for built-in types.
3146:             * <p>The JDBC specification specifies a standard mapping from Java
3147:             * <code>Object</code> types to SQL types. The given argument will be
3148:             * converted to the corresponding SQL type before being sent to the
3149:             * database.
3150:             * <p>Note that this method may be used to pass datatabase-specific
3151:             * abstract data types, by using a driver-specific Java type.
3152:             * <p>If the object is of a class implementing the interface
3153:             * <code>SQLData</code>, the JDBC driver should call the method
3154:             * <code>SQLData.writeSQL</code> to write it to the SQL data stream.
3155:             * If, on the other hand, the object is of a class implementing
3156:             * <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
3157:             * <code>Struct</code>, or <code>Array</code>, the driver should pass
3158:             * it to the database as a value of the corresponding SQL type.
3159:             * <p>This method throws an exception if there is an ambiguity, for
3160:             * example, if the object is of a class implementing more than one of
3161:             * the interfaces named above.
3162:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3163:             * is automatically closed and an ongoing transaction will be
3164:             * automatically rolled back if it belongs to the executing thread.
3165:             *
3166:             * @param parameterIndices the first parameter is 1, the second is 2,
3167:             * ...
3168:             * @param x the object containing the input parameter value
3169:             * @return this <code>DbPreparedStatement</code> instance.
3170:             * @exception DatabaseException if a database access error occurs or
3171:             * the type of the given object is ambiguous
3172:             * @see #setObject(String, Object)
3173:             * @see #setObject(int, Object)
3174:             * @since 1.0
3175:             */
3176:            public DbPreparedStatement setObjects(int[] parameterIndices,
3177:                    Object x) throws DatabaseException {
3178:                if (null == parameterIndices)
3179:                    throw new IllegalArgumentException(
3180:                            "parameterIndices can't be null.");
3181:
3182:                for (int parameter_index : parameterIndices) {
3183:                    setObject(parameter_index, x);
3184:                }
3185:
3186:                return this ;
3187:            }
3188:
3189:            /**
3190:             * Sets the value of the designated parameter using the given object.
3191:             * The second parameter must be of type <code>Object</code>;
3192:             * therefore, the <code>java.lang</code> equivalent objects should be
3193:             * used for built-in types.
3194:             * <p>The JDBC specification specifies a standard mapping from Java
3195:             * <code>Object</code> types to SQL types. The given argument will be
3196:             * converted to the corresponding SQL type before being sent to the
3197:             * database.
3198:             * <p>Note that this method may be used to pass datatabase-specific
3199:             * abstract data types, by using a driver-specific Java type.
3200:             * <p>If the object is of a class implementing the interface
3201:             * <code>SQLData</code>, the JDBC driver should call the method
3202:             * <code>SQLData.writeSQL</code> to write it to the SQL data stream.
3203:             * If, on the other hand, the object is of a class implementing
3204:             * <code>Ref</code>, <code>Blob</code>, <code>Clob</code>,
3205:             * <code>Struct</code>, or <code>Array</code>, the driver should pass
3206:             * it to the database as a value of the corresponding SQL type.
3207:             * <p>This method throws an exception if there is an ambiguity, for
3208:             * example, if the object is of a class implementing more than one of
3209:             * the interfaces named above.
3210:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3211:             * is automatically closed and an ongoing transaction will be
3212:             * automatically rolled back if it belongs to the executing thread.
3213:             *
3214:             * @param parameterIndex the first parameter is 1, the second is 2,
3215:             * ...
3216:             * @param x the object containing the input parameter value
3217:             * @return this <code>DbPreparedStatement</code> instance.
3218:             * @exception DatabaseException if a database access error occurs or
3219:             * the type of the given object is ambiguous
3220:             * @see #setObject(String, Object)
3221:             * @see #setObjects(int[], Object)
3222:             * @since 1.0
3223:             */
3224:            public DbPreparedStatement setObject(int parameterIndex, Object x)
3225:                    throws DatabaseException {
3226:                // handle virtual parameters
3227:                if (mVirtualParameters != null
3228:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3229:                    int real_index = mVirtualParameters
3230:                            .getRealIndex(parameterIndex);
3231:                    if (-1 == real_index) {
3232:                        mVirtualParameters.putValue(parameterIndex, x);
3233:                        return this ;
3234:                    } else {
3235:                        parameterIndex = real_index;
3236:                    }
3237:                }
3238:
3239:                // set the real parameter
3240:                try {
3241:                    ((PreparedStatement) mStatement).setObject(parameterIndex,
3242:                            x);
3243:                } catch (SQLException e) {
3244:                    handleException();
3245:                    throw new DatabaseException(e);
3246:                }
3247:
3248:                return this ;
3249:            }
3250:
3251:            /**
3252:             * Sets the named parameter to the given
3253:             * <code>REF(&lt;structured-type&gt;)</code> value. The driver
3254:             * converts this to a SQL <code>REF</code> value when it sends it to
3255:             * the database.
3256:             * <p>If a database access error occurs, this
3257:             * <code>DbPreparedStatement</code> instance is automatically closed.
3258:             *
3259:             * @param parameterName the name of the parameter that will be set
3260:             * (the first parameter with the name will be used)
3261:             * @param x an SQL <code>REF</code> value
3262:             * @return this <code>DbPreparedStatement</code> instance.
3263:             * @exception DatabaseException when this
3264:             * <code>DbPrepareStatement</code> instance wasn't defined by a
3265:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
3266:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
3267:             * or if no parameters with this name could be found, or if a database
3268:             * access error occurs.
3269:             * @see #setRef(int, Ref)
3270:             * @since 1.0
3271:             */
3272:            public DbPreparedStatement setRef(String parameterName, Ref x)
3273:                    throws DatabaseException {
3274:                setRef(getParameterIndices(parameterName)[0], x);
3275:
3276:                return this ;
3277:            }
3278:
3279:            /**
3280:             * Sets the designated parameter to the given
3281:             * <code>REF(&lt;structured-type&gt;)</code> value. The driver
3282:             * converts this to a SQL <code>REF</code> value when it sends it to
3283:             * the database.
3284:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3285:             * is automatically closed and an ongoing transaction will be
3286:             * automatically rolled back if it belongs to the executing thread.
3287:             *
3288:             * @param parameterIndex the first parameter is 1, the second is 2,
3289:             * ...
3290:             * @param x an SQL <code>REF</code> value
3291:             * @return this <code>DbPreparedStatement</code> instance.
3292:             * @exception DatabaseException if a database access error occurs
3293:             * @see #setRef(String, Ref)
3294:             * @since 1.0
3295:             */
3296:            public DbPreparedStatement setRef(int parameterIndex, Ref x)
3297:                    throws DatabaseException {
3298:                // handle virtual parameters
3299:                if (mVirtualParameters != null
3300:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3301:                    int real_index = mVirtualParameters
3302:                            .getRealIndex(parameterIndex);
3303:                    if (-1 == real_index) {
3304:                        throw new UnsupportedVirtualParameterTypeException(
3305:                                this , parameterIndex, x.getClass().getName());
3306:                    } else {
3307:                        parameterIndex = real_index;
3308:                    }
3309:                }
3310:
3311:                // set the real parameter
3312:                try {
3313:                    ((PreparedStatement) mStatement).setRef(parameterIndex, x);
3314:                } catch (SQLException e) {
3315:                    handleException();
3316:                    throw new DatabaseException(e);
3317:                }
3318:
3319:                return this ;
3320:            }
3321:
3322:            /**
3323:             * Sets the named parameter to the given <code>Blob</code> object. The
3324:             * driver converts this to a SQL <code>BLOB</code> value when it sends
3325:             * it to the database.
3326:             * <p>If a database access error occurs, this
3327:             * <code>DbPreparedStatement</code> instance is automatically closed.
3328:             *
3329:             * @param parameterName the name of the parameter that will be set
3330:             * (the first parameter with the name will be used)
3331:             * @param x a <code>Blob</code> object that maps an SQL
3332:             * <code>BLOB</code> value
3333:             * @return this <code>DbPreparedStatement</code> instance.
3334:             * @exception DatabaseException when this
3335:             * <code>DbPrepareStatement</code> instance wasn't defined by a
3336:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
3337:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
3338:             * or if no parameters with this name could be found, or if a database
3339:             * access error occurs.
3340:             * @see #setBlob(String, Blob)
3341:             * @since 1.0
3342:             */
3343:            public DbPreparedStatement setBlob(String parameterName, Blob x)
3344:                    throws DatabaseException {
3345:                setBlob(getParameterIndices(parameterName)[0], x);
3346:
3347:                return this ;
3348:            }
3349:
3350:            /**
3351:             * Sets the designated parameter to the given <code>Blob</code>
3352:             * object. The driver converts this to a SQL <code>BLOB</code> value
3353:             * when it sends it to the database.
3354:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3355:             * is automatically closed and an ongoing transaction will be
3356:             * automatically rolled back if it belongs to the executing thread.
3357:             *
3358:             * @param parameterIndex the first parameter is 1, the second is 2,
3359:             * ...
3360:             * @param x a <code>Blob</code> object that maps an SQL
3361:             * <code>BLOB</code> value
3362:             * @return this <code>DbPreparedStatement</code> instance.
3363:             * @exception DatabaseException if a database access error occurs
3364:             * @see #setBlob(String, Blob)
3365:             * @since 1.0
3366:             */
3367:            public DbPreparedStatement setBlob(int parameterIndex, Blob x)
3368:                    throws DatabaseException {
3369:                // handle virtual parameters
3370:                if (mVirtualParameters != null
3371:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3372:                    int real_index = mVirtualParameters
3373:                            .getRealIndex(parameterIndex);
3374:                    if (-1 == real_index) {
3375:                        throw new UnsupportedVirtualParameterTypeException(
3376:                                this , parameterIndex, x.getClass().getName());
3377:                    } else {
3378:                        parameterIndex = real_index;
3379:                    }
3380:                }
3381:
3382:                // set the real parameter
3383:                try {
3384:                    ((PreparedStatement) mStatement).setBlob(parameterIndex, x);
3385:                } catch (SQLException e) {
3386:                    handleException();
3387:                    throw new DatabaseException(e);
3388:                }
3389:
3390:                return this ;
3391:            }
3392:
3393:            /**
3394:             * Sets the named parameter to the given <code>Clob</code> object. The
3395:             * driver converts this to a SQL <code>CLOB</code> value when it sends
3396:             * it to the database.
3397:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3398:             * is automatically closed and an ongoing transaction will be
3399:             * automatically rolled back if it belongs to the executing thread.
3400:             *
3401:             * @param parameterName the name of the parameter that will be set
3402:             * (the first parameter with the name will be used)
3403:             * @param x a <code>Clob</code> object that maps an SQL
3404:             * <code>CLOB</code> value
3405:             * @return this <code>DbPreparedStatement</code> instance.
3406:             * @exception DatabaseException when this
3407:             * <code>DbPrepareStatement</code> instance wasn't defined by a
3408:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
3409:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
3410:             * or if no parameters with this name could be found, or if a database
3411:             * access error occurs.
3412:             * @see #setClob(int, Clob)
3413:             * @since 1.0
3414:             */
3415:            public DbPreparedStatement setClob(String parameterName, Clob x)
3416:                    throws DatabaseException {
3417:                setClob(getParameterIndices(parameterName)[0], x);
3418:
3419:                return this ;
3420:            }
3421:
3422:            /**
3423:             * Sets the designated parameter to the given <code>Clob</code>
3424:             * object. The driver converts this to a SQL <code>CLOB</code> value
3425:             * when it sends it to the database.
3426:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3427:             * is automatically closed and an ongoing transaction will be
3428:             * automatically rolled back if it belongs to the executing thread.
3429:             *
3430:             * @param parameterIndex the first parameter is 1, the second is 2,
3431:             * ...
3432:             * @param x a <code>Clob</code> object that maps an SQL
3433:             * <code>CLOB</code> value
3434:             * @return this <code>DbPreparedStatement</code> instance.
3435:             * @exception DatabaseException if a database access error occurs
3436:             * @see #setClob(String, Clob)
3437:             * @since 1.0
3438:             */
3439:            public DbPreparedStatement setClob(int parameterIndex, Clob x)
3440:                    throws DatabaseException {
3441:                // handle virtual parameters
3442:                if (mVirtualParameters != null
3443:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3444:                    int real_index = mVirtualParameters
3445:                            .getRealIndex(parameterIndex);
3446:                    if (-1 == real_index) {
3447:                        throw new UnsupportedVirtualParameterTypeException(
3448:                                this , parameterIndex, x.getClass().getName());
3449:                    } else {
3450:                        parameterIndex = real_index;
3451:                    }
3452:                }
3453:
3454:                // set the real parameter
3455:                try {
3456:                    ((PreparedStatement) mStatement).setClob(parameterIndex, x);
3457:                } catch (SQLException e) {
3458:                    handleException();
3459:                    throw new DatabaseException(e);
3460:                }
3461:
3462:                return this ;
3463:            }
3464:
3465:            /**
3466:             * Sets the named parameters to the given <code>java.net.URL</code>
3467:             * value. The driver converts this to a SQL <code>DATALINK</code>
3468:             * value when it sends it to the database.
3469:             * <p>If a database access error occurs, this
3470:             * <code>DbPreparedStatement</code> instance is automatically closed.
3471:             *
3472:             * @param parameterName the name of the parameters that have to be set
3473:             * @param x the <code>java.net.URL</code> object to be set
3474:             * @return this <code>DbPreparedStatement</code> instance.
3475:             * @exception DatabaseException when this
3476:             * <code>DbPrepareStatement</code> instance wasn't defined by a
3477:             * <code>ParametrizedQuery</code> but by a regular sql string, or if
3478:             * the <code>ParametrizedQuery</code> doesn't contain any parameters,
3479:             * or if no parameters with this name could be found, or if a database
3480:             * access error occurs.
3481:             * @see #setURLs(int[], URL)
3482:             * @see #setURL(int, URL)
3483:             * @since 1.0
3484:             */
3485:            public DbPreparedStatement setURL(String parameterName, URL x)
3486:                    throws DatabaseException {
3487:                setURLs(getParameterIndices(parameterName), x);
3488:
3489:                return this ;
3490:            }
3491:
3492:            /**
3493:             * Sets the designated parameters to the given
3494:             * <code>java.net.URL</code> value. The driver converts this to a SQL
3495:             * <code>DATALINK</code> value when it sends it to the database.
3496:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3497:             * is automatically closed and an ongoing transaction will be
3498:             * automatically rolled back if it belongs to the executing thread.
3499:             *
3500:             * @param parameterIndices the first parameter is 1, the second is 2,
3501:             * ...
3502:             * @param x the <code>java.net.URL</code> object to be set
3503:             * @return this <code>DbPreparedStatement</code> instance.
3504:             * @exception DatabaseException if a database access error occurs
3505:             * @see #setURL(String, URL)
3506:             * @see #setURL(int, URL)
3507:             * @since 1.0
3508:             */
3509:            public DbPreparedStatement setURLs(int[] parameterIndices, URL x)
3510:                    throws DatabaseException {
3511:                if (null == parameterIndices)
3512:                    throw new IllegalArgumentException(
3513:                            "parameterIndices can't be null.");
3514:
3515:                for (int parameter_index : parameterIndices) {
3516:                    setURL(parameter_index, x);
3517:                }
3518:
3519:                return this ;
3520:            }
3521:
3522:            /**
3523:             * Sets the designated parameter to the given
3524:             * <code>java.net.URL</code> value. The driver converts this to a SQL
3525:             * <code>DATALINK</code> value when it sends it to the database.
3526:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3527:             * is automatically closed and an ongoing transaction will be
3528:             * automatically rolled back if it belongs to the executing thread.
3529:             *
3530:             * @param parameterIndex the first parameter is 1, the second is 2, ...
3531:             * @param x the <code>java.net.URL</code> object to be set
3532:             * @return this <code>DbPreparedStatement</code> instance.
3533:             * @exception DatabaseException if a database access error occurs
3534:             * @see #setURL(String, URL)
3535:             * @see #setURLs(int[], URL)
3536:             * @since 1.0
3537:             */
3538:            public DbPreparedStatement setURL(int parameterIndex, URL x)
3539:                    throws DatabaseException {
3540:                // handle virtual parameters
3541:                if (mVirtualParameters != null
3542:                        && mVirtualParameters.hasParameter(parameterIndex)) {
3543:                    int real_index = mVirtualParameters
3544:                            .getRealIndex(parameterIndex);
3545:                    if (-1 == real_index) {
3546:                        mVirtualParameters.putValue(parameterIndex, x);
3547:                        return this ;
3548:                    } else {
3549:                        parameterIndex = real_index;
3550:                    }
3551:                }
3552:
3553:                // set the real parameter
3554:                try {
3555:                    ((PreparedStatement) mStatement).setURL(parameterIndex, x);
3556:                } catch (SQLException e) {
3557:                    handleException();
3558:                    throw new DatabaseException(e);
3559:                }
3560:
3561:                return this ;
3562:            }
3563:
3564:            /**
3565:             * Clears the current parameter values immediately.
3566:             * <p>In general, parameter values remain in force for repeated use of
3567:             * a statement. Setting a parameter value automatically clears its
3568:             * previous value. However, in some cases it is useful to immediately
3569:             * release the resources used by the current parameter values; this
3570:             * can be done by calling the method <code>clearParameters</code>.
3571:             * <p>If an exception is thrown, this <code>DbPreparedStatement</code>
3572:             * is automatically closed and an ongoing transaction will be
3573:             * automatically rolled back if it belongs to the executing thread.
3574:             *
3575:             * @exception DatabaseException if a database access error occurs
3576:             * @since 1.0
3577:             */
3578:            public void clearParameters() throws DatabaseException {
3579:                try {
3580:                    ((PreparedStatement) mStatement).clearParameters();
3581:                } catch (SQLException e) {
3582:                    handleException();
3583:                    throw new DatabaseException(e);
3584:                }
3585:            }
3586:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.