KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > jdbc > DjPreparedStatement


1 /*
2  * Copyright (c) 2001-2005 by Genimen BV (www.genimen.com) All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, is permitted provided that the following conditions are met: -
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer. - Redistributions in binary
8  * form must reproduce the above copyright notice, this list of conditions and
9  * the following disclaimer in the documentation and/or other materials
10  * provided with the distribution. - All advertising materials mentioning
11  * features or use of this software must display the following acknowledgment:
12  * "This product includes Djeneric." - Products derived from this software may
13  * not be called "Djeneric" nor may "Djeneric" appear in their names without
14  * prior written permission of Genimen BV. - Redistributions of any form
15  * whatsoever must retain the following acknowledgment: "This product includes
16  * Djeneric."
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL GENIMEN BV, DJENERIC.ORG, OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package com.genimen.djeneric.jdbc;
32
33 import java.math.BigDecimal JavaDoc;
34 import java.net.URL JavaDoc;
35 import java.sql.Array JavaDoc;
36 import java.sql.Blob JavaDoc;
37 import java.sql.Clob JavaDoc;
38 import java.sql.Connection JavaDoc;
39 import java.sql.DriverManager JavaDoc;
40 import java.sql.ParameterMetaData JavaDoc;
41 import java.sql.PreparedStatement JavaDoc;
42 import java.sql.Ref JavaDoc;
43 import java.sql.ResultSet JavaDoc;
44 import java.sql.ResultSetMetaData JavaDoc;
45 import java.sql.SQLException JavaDoc;
46 import java.sql.SQLWarning JavaDoc;
47 import java.util.Calendar JavaDoc;
48
49 import com.genimen.djeneric.repository.exceptions.DjenericException;
50 import com.genimen.djeneric.repository.rdbms.RdbmsSession;
51 import com.genimen.djeneric.repository.rdbms.SqlStatement;
52
53 /**
54  * @author Gert Rijs
55  * @version 1.0
56  */

57
58 public class DjPreparedStatement implements PreparedStatement JavaDoc
59 {
60   private static final String JavaDoc CLASSNAME = DjPreparedStatement.class.getName();
61   private DjConnection _connection = null;
62   private SqlStatement _underlyingSqlStatement = null;
63
64   private String JavaDoc _originalSqlStatement = null; // select * from supplyers
65
private String JavaDoc _polymorphStatement = null; // select * from polymorph where
66

67   // table_type = 'supp'
68

69   public DjPreparedStatement(DjConnection p_con, String JavaDoc p_sql) throws SQLException JavaDoc
70   {
71     this(p_con, p_sql, 0, ResultSet.CONCUR_READ_ONLY);
72   }
73
74   public DjPreparedStatement(DjConnection p_con, String JavaDoc p_sql, int resultSetType, int resultSetConcurrency)
75       throws SQLException JavaDoc
76   {
77     if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) throw new SQLException JavaDoc(
78         "djeneric jdbc-driver can only handle SELECT statements");
79     _connection = p_con;
80     _originalSqlStatement = p_sql;
81     _polymorphStatement = _connection.translateSqlToPolymorph(p_sql);
82     DriverManager.println("original sql : " + _originalSqlStatement);
83     DriverManager.println("translated to sql: " + _polymorphStatement);
84     if (_polymorphStatement.toLowerCase().trim().startsWith("select ") == false) throw new SQLException JavaDoc(
85         "djeneric jdbc-driver can only handle SELECT statements");
86
87     try
88     {
89       RdbmsSession s = (RdbmsSession) _connection.getPersistenceManager().createSession();
90       _underlyingSqlStatement = s.getInternalSqlStatement(_polymorphStatement);
91     }
92     catch (DjenericException de)
93     {
94       throw new SQLException JavaDoc(de.toString());
95     }
96   }
97
98   /**
99    * Executes the SQL query in this <code>PreparedStatement</code> object and
100    * returns the result set generated by the query.
101    *
102    * @return a <code>ResultSet</code> object that contains the data produced
103    * by the query; never <code>null</code>
104    * @exception SQLException
105    * if a database access error occurs
106    */

107   public ResultSet JavaDoc executeQuery() throws SQLException JavaDoc
108   {
109     return _underlyingSqlStatement.executeQuery();
110   }
111
112   /**
113    * Executes the SQL INSERT, UPDATE or DELETE statement in this <code>PreparedStatement</code>
114    * object. In addition, SQL statements that return nothing, such as SQL DDL
115    * statements, can be executed.
116    *
117    * @return either the row count for INSERT, UPDATE or DELETE statements; or 0
118    * for SQL statements that return nothing
119    * @exception SQLException
120    * if a database access error occurs
121    */

122   public int executeUpdate() throws SQLException JavaDoc
123   {
124     throw new SQLException JavaDoc("djeneric jdbc-driver can only handle SELECT statements");
125   }
126
127   /**
128    * Sets the designated parameter to SQL <code>NULL</code>.
129    *
130    * <P>
131    * <B>Note:</B> You must specify the parameter's SQL type.
132    *
133    * @param parameterIndex
134    * the first parameter is 1, the second is 2, ...
135    * @param sqlType
136    * the SQL type code defined in <code>java.sql.Types</code>
137    * @exception SQLException
138    * if a database access error occurs
139    */

140   public void setNull(int parameterIndex, int sqlType) throws SQLException JavaDoc
141   {
142     _underlyingSqlStatement.getStmt().setNull(parameterIndex, sqlType);
143   }
144
145   /**
146    * Sets the designated parameter to a Java <code>boolean</code> value. The
147    * driver converts this to an SQL <code>BIT</code> value when it sends it
148    * to the database.
149    *
150    * @param parameterIndex
151    * the first parameter is 1, the second is 2, ...
152    * @param x
153    * the parameter value
154    * @exception SQLException
155    * if a database access error occurs
156    */

157   public void setBoolean(int parameterIndex, boolean x) throws SQLException JavaDoc
158   {
159     _underlyingSqlStatement.getStmt().setBoolean(parameterIndex, x);
160   }
161
162   /**
163    * Sets the designated parameter to a Java <code>byte</code> value. The
164    * driver converts this to an SQL <code>TINYINT</code> value when it sends
165    * it to the database.
166    *
167    * @param parameterIndex
168    * the first parameter is 1, the second is 2, ...
169    * @param x
170    * the parameter value
171    * @exception SQLException
172    * if a database access error occurs
173    */

174   public void setByte(int parameterIndex, byte x) throws SQLException JavaDoc
175   {
176     _underlyingSqlStatement.getStmt().setByte(parameterIndex, x);
177   }
178
179   /**
180    * Sets the designated parameter to a Java <code>short</code> value. The
181    * driver converts this to an SQL <code>SMALLINT</code> value when it sends
182    * it to the database.
183    *
184    * @param parameterIndex
185    * the first parameter is 1, the second is 2, ...
186    * @param x
187    * the parameter value
188    * @exception SQLException
189    * if a database access error occurs
190    */

191   public void setShort(int parameterIndex, short x) throws SQLException JavaDoc
192   {
193     _underlyingSqlStatement.getStmt().setShort(parameterIndex, x);
194   }
195
196   /**
197    * Sets the designated parameter to a Java <code>int</code> value. The
198    * driver converts this to an SQL <code>INTEGER</code> value when it sends
199    * it to the database.
200    *
201    * @param parameterIndex
202    * the first parameter is 1, the second is 2, ...
203    * @param x
204    * the parameter value
205    * @exception SQLException
206    * if a database access error occurs
207    */

208   public void setInt(int parameterIndex, int x) throws SQLException JavaDoc
209   {
210     _underlyingSqlStatement.getStmt().setInt(parameterIndex, x);
211   }
212
213   /**
214    * Sets the designated parameter to a Java <code>long</code> value. The
215    * driver converts this to an SQL <code>BIGINT</code> value when it sends
216    * it to the database.
217    *
218    * @param parameterIndex
219    * the first parameter is 1, the second is 2, ...
220    * @param x
221    * the parameter value
222    * @exception SQLException
223    * if a database access error occurs
224    */

225   public void setLong(int parameterIndex, long x) throws SQLException JavaDoc
226   {
227     _underlyingSqlStatement.getStmt().setLong(parameterIndex, x);
228   }
229
230   /**
231    * Sets the designated parameter to a Java <code>float</code> value. The
232    * driver converts this to an SQL <code>FLOAT</code> value when it sends it
233    * to the database.
234    *
235    * @param parameterIndex
236    * the first parameter is 1, the second is 2, ...
237    * @param x
238    * the parameter value
239    * @exception SQLException
240    * if a database access error occurs
241    */

242   public void setFloat(int parameterIndex, float x) throws SQLException JavaDoc
243   {
244     _underlyingSqlStatement.getStmt().setFloat(parameterIndex, x);
245   }
246
247   /**
248    * Sets the designated parameter to a Java <code>double</code> value. The
249    * driver converts this to an SQL <code>DOUBLE</code> value when it sends
250    * it to the database.
251    *
252    * @param parameterIndex
253    * the first parameter is 1, the second is 2, ...
254    * @param x
255    * the parameter value
256    * @exception SQLException
257    * if a database access error occurs
258    */

259   public void setDouble(int parameterIndex, double x) throws SQLException JavaDoc
260   {
261     _underlyingSqlStatement.getStmt().setDouble(parameterIndex, x);
262   }
263
264   /**
265    * Sets the designated parameter to a <code>java.math.BigDecimal</code>
266    * value. The driver converts this to an SQL <code>NUMERIC</code> value
267    * when it sends it to the database.
268    *
269    * @param parameterIndex
270    * the first parameter is 1, the second is 2, ...
271    * @param x
272    * the parameter value
273    * @exception SQLException
274    * if a database access error occurs
275    */

276   public void setBigDecimal(int parameterIndex, BigDecimal JavaDoc x) throws SQLException JavaDoc
277   {
278     _underlyingSqlStatement.getStmt().setBigDecimal(parameterIndex, x);
279   }
280
281   /**
282    * Sets the designated parameter to a Java <code>String</code> value. The
283    * driver converts this to an SQL <code>VARCHAR</code> or <code>LONGVARCHAR</code>
284    * value (depending on the argument's size relative to the driver's limits on
285    * <code>VARCHAR</code> values) when it sends it to the database.
286    *
287    * @param parameterIndex
288    * the first parameter is 1, the second is 2, ...
289    * @param x
290    * the parameter value
291    * @exception SQLException
292    * if a database access error occurs
293    */

294   public void setString(int parameterIndex, String JavaDoc x) throws SQLException JavaDoc
295   {
296     _underlyingSqlStatement.getStmt().setString(parameterIndex, x);
297   }
298
299   /**
300    * Sets the designated parameter to a Java array of bytes. The driver
301    * converts this to an SQL <code>VARBINARY</code> or <code>LONGVARBINARY</code>
302    * (depending on the argument's size relative to the driver's limits on
303    * <code>VARBINARY</code> values) when it sends it to the database.
304    *
305    * @param parameterIndex
306    * the first parameter is 1, the second is 2, ...
307    * @param x
308    * the parameter value
309    * @exception SQLException
310    * if a database access error occurs
311    */

312   public void setBytes(int parameterIndex, byte x[]) throws SQLException JavaDoc
313   {
314     _underlyingSqlStatement.getStmt().setBytes(parameterIndex, x);
315   }
316
317   /**
318    * Sets the designated parameter to a <code<java.sql.Date</code> value.
319    * * The driver converts this
320    * to an SQL <code>DATE</code> value when it sends it to the database.
321    * *
322    * @param parameterIndex the first parameter is 1, the second is 2, ...
323    * @param x the parameter value
324    * @exception SQLException if a database access error occurs
325    */

326   public void setDate(int parameterIndex, java.sql.Date JavaDoc x) throws SQLException JavaDoc
327   {
328     _underlyingSqlStatement.getStmt().setDate(parameterIndex, x);
329   }
330
331   /**
332    * Sets the designated parameter to a <code>java.sql.Time</code> value. The
333    * driver converts this to an SQL <code>TIME</code> value when it sends it
334    * to the database.
335    *
336    * @param parameterIndex
337    * the first parameter is 1, the second is 2, ...
338    * @param x
339    * the parameter value
340    * @exception SQLException
341    * if a database access error occurs
342    */

343   public void setTime(int parameterIndex, java.sql.Time JavaDoc x) throws SQLException JavaDoc
344   {
345     _underlyingSqlStatement.getStmt().setTime(parameterIndex, x);
346   }
347
348   /**
349    * Sets the designated parameter to a <code>java.sql.Timestamp</code>
350    * value. The driver converts this to an SQL <code>TIMESTAMP</code> value
351    * when it sends it to the database.
352    *
353    * @param parameterIndex
354    * the first parameter is 1, the second is 2, ...
355    * @param x
356    * the parameter value
357    * @exception SQLException
358    * if a database access error occurs
359    */

360   public void setTimestamp(int parameterIndex, java.sql.Timestamp JavaDoc x) throws SQLException JavaDoc
361   {
362     _underlyingSqlStatement.getStmt().setTimestamp(parameterIndex, x);
363   }
364
365   /**
366    * Sets the designated parameter to the given input stream, which will have
367    * the specified number of bytes. When a very large ASCII value is input to a
368    * <code>LONGVARCHAR</code> parameter, it may be more practical to send it
369    * via a <code>java.io.InputStream</code>. Data will be read from the
370    * stream as needed until end-of-file is reached. The JDBC driver will do any
371    * necessary conversion from ASCII to the database char format.
372    *
373    * <P>
374    * <B>Note:</B> This stream object can either be a standard Java stream
375    * object or your own subclass that implements the standard interface.
376    *
377    * @param parameterIndex
378    * the first parameter is 1, the second is 2, ...
379    * @param x
380    * the Java input stream that contains the ASCII parameter value
381    * @param length
382    * the number of bytes in the stream
383    * @exception SQLException
384    * if a database access error occurs
385    */

386   public void setAsciiStream(int parameterIndex, java.io.InputStream JavaDoc x, int length) throws SQLException JavaDoc
387   {
388     _underlyingSqlStatement.getStmt().setAsciiStream(parameterIndex, x, length);
389   }
390
391   /**
392    * Sets the designated parameter to the given input stream, which will have
393    * the specified number of bytes. When a very large UNICODE value is input to
394    * a <code>LONGVARCHAR</code> parameter, it may be more practical to send
395    * it via a <code>java.io.InputStream</code> object. The data will be read
396    * from the stream as needed until end-of-file is reached. The JDBC driver
397    * will do any necessary conversion from UNICODE to the database char format.
398    * The byte format of the Unicode stream must be Java UTF-8, as defined in
399    * the Java Virtual Machine Specification.
400    *
401    * <P>
402    * <B>Note:</B> This stream object can either be a standard Java stream
403    * object or your own subclass that implements the standard interface.
404    *
405    * @param parameterIndex
406    * the first parameter is 1, the second is 2, ...
407    * @param x
408    * the java input stream which contains the UNICODE parameter
409    * value
410    * @param length
411    * the number of bytes in the stream
412    * @exception SQLException
413    * if a database access error occurs
414    * @deprecated
415    */

416   public void setUnicodeStream(int parameterIndex, java.io.InputStream JavaDoc x, int length) throws SQLException JavaDoc
417   {
418     _underlyingSqlStatement.getStmt().setUnicodeStream(parameterIndex, x, length);
419   }
420
421   /**
422    * Sets the designated parameter to the given input stream, which will have
423    * the specified number of bytes. When a very large binary value is input to
424    * a <code>LONGVARBINARY</code> parameter, it may be more practical to send
425    * it via a <code>java.io.InputStream</code> object. The data will be read
426    * from the stream as needed until end-of-file is reached.
427    *
428    * <P>
429    * <B>Note:</B> This stream object can either be a standard Java stream
430    * object or your own subclass that implements the standard interface.
431    *
432    * @param parameterIndex
433    * the first parameter is 1, the second is 2, ...
434    * @param x
435    * the java input stream which contains the binary parameter value
436    * @param length
437    * the number of bytes in the stream
438    * @exception SQLException
439    * if a database access error occurs
440    */

441   public void setBinaryStream(int parameterIndex, java.io.InputStream JavaDoc x, int length) throws SQLException JavaDoc
442   {
443     _underlyingSqlStatement.getStmt().setBinaryStream(parameterIndex, x, length);
444   }
445
446   /**
447    * Clears the current parameter values immediately.
448    * <P>
449    * In general, parameter values remain in force for repeated use of a
450    * statement. Setting a parameter value automatically clears its previous
451    * value. However, in some cases it is useful to immediately release the
452    * resources used by the current parameter values; this can be done by
453    * calling the method <code>clearParameters</code>.
454    *
455    * @exception SQLException
456    * if a database access error occurs
457    */

458   public void clearParameters() throws SQLException JavaDoc
459   {
460     _underlyingSqlStatement.getStmt().clearParameters();
461   }
462
463   //----------------------------------------------------------------------
464
// Advanced features:
465

466   /**
467    * <p>
468    * Sets the value of the designated parameter with the given object. The
469    * second argument must be an object type; for integral values, the <code>java.lang</code>
470    * equivalent objects should be used.
471    *
472    * <p>
473    * The given Java object will be converted to the given targetSqlType before
474    * being sent to the database.
475    *
476    * If the object has a custom mapping (is of a class implementing the
477    * interface <code>SQLData</code>), the JDBC driver should call the method
478    * <code>SQLData.writeSQL</code> to write it to the SQL data stream. If, on
479    * the other hand, the object is of a class implementing Ref, Blob, Clob,
480    * Struct, or Array, the driver should pass it to the database as a value of
481    * the corresponding SQL type.
482    *
483    * <p>
484    * Note that this method may be used to pass datatabase- specific abstract
485    * data types.
486    *
487    * @param parameterIndex
488    * the first parameter is 1, the second is 2, ...
489    * @param x
490    * the object containing the input parameter value
491    * @param targetSqlType
492    * the SQL type (as defined in java.sql.Types) to be sent to the
493    * database. The scale argument may further qualify this type.
494    * @param scale
495    * for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
496    * this is the number of digits after the decimal point. For all
497    * other types, this value will be ignored.
498    * @exception SQLException
499    * if a database access error occurs
500    * @see Types
501    */

502   public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType, int scale) throws SQLException JavaDoc
503   {
504     _underlyingSqlStatement.getStmt().setObject(parameterIndex, x, targetSqlType, scale);
505   }
506
507   /**
508    * Sets the value of the designated parameter with the given object. This
509    * method is like the method <code>setObject</code> above, except that it
510    * assumes a scale of zero.
511    *
512    * @param parameterIndex
513    * the first parameter is 1, the second is 2, ...
514    * @param x
515    * the object containing the input parameter value
516    * @param targetSqlType
517    * the SQL type (as defined in java.sql.Types) to be sent to the
518    * database
519    * @exception SQLException
520    * if a database access error occurs
521    */

522   public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType) throws SQLException JavaDoc
523   {
524     _underlyingSqlStatement.getStmt().setObject(parameterIndex, x, targetSqlType);
525   }
526
527   /**
528    * <p>
529    * Sets the value of the designated parameter using the given object. The
530    * second parameter must be of type <code>Object</code>; therefore, the
531    * <code>java.lang</code> equivalent objects should be used for built-in
532    * types.
533    *
534    * <p>
535    * The JDBC specification specifies a standard mapping from Java <code>Object</code>
536    * types to SQL types. The given argument will be converted to the
537    * corresponding SQL type before being sent to the database.
538    *
539    * <p>
540    * Note that this method may be used to pass datatabase- specific abstract
541    * data types, by using a driver-specific Java type.
542    *
543    * If the object is of a class implementing the interface <code>SQLData</code>,
544    * the JDBC driver should call the method <code>SQLData.writeSQL</code> to
545    * write it to the SQL data stream. If, on the other hand, the object is of a
546    * class implementing Ref, Blob, Clob, Struct, or Array, then the driver
547    * should pass it to the database as a value of the corresponding SQL type.
548    *
549    * This method throws an exception if there is an ambiguity, for example, if
550    * the object is of a class implementing more than one of the interfaces
551    * named above.
552    *
553    * @param parameterIndex
554    * the first parameter is 1, the second is 2, ...
555    * @param x
556    * the object containing the input parameter value
557    * @exception SQLException
558    * if a database access error occurs
559    */

560   public void setObject(int parameterIndex, Object JavaDoc x) throws SQLException JavaDoc
561   {
562     _underlyingSqlStatement.getStmt().setObject(parameterIndex, x);
563   }
564
565   /**
566    * Executes any kind of SQL statement. Some prepared statements return
567    * multiple results; the <code>execute</code> method handles these complex
568    * statements as well as the simpler form of statements handled by the
569    * methods <code>executeQuery</code> and <code>executeUpdate</code>.
570    *
571    * @exception SQLException
572    * if a database access error occurs
573    * @see Statement#execute
574    */

575   public boolean execute() throws SQLException JavaDoc
576   {
577     throw new SQLException JavaDoc("ps.execute: this method is not implemented by the djeneric driver");
578   }
579
580   //--------------------------JDBC 2.0-----------------------------
581

582   /**
583    * Adds a set of parameters to this <code>PreparedStatement</code> object's
584    * batch of commands.
585    *
586    * @exception SQLException
587    * if a database access error occurs
588    * @see Statement#addBatch
589    * @since 1.2
590    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
591    * </a>
592    */

593   public void addBatch() throws SQLException JavaDoc
594   {
595     throw new SQLException JavaDoc("ps.addBatch: this method is not implemented by the djeneric driver");
596   }
597
598   /**
599    * Sets the designated parameter to the given <code>Reader</code> object,
600    * which is the given number of characters long. When a very large UNICODE
601    * value is input to a <code>LONGVARCHAR</code> parameter, it may be more
602    * practical to send it via a <code>java.io.Reader</code> object. The data
603    * will be read from the stream as needed until end-of-file is reached. The
604    * JDBC driver will do any necessary conversion from UNICODE to the database
605    * char format.
606    *
607    * <P>
608    * <B>Note:</B> This stream object can either be a standard Java stream
609    * object or your own subclass that implements the standard interface.
610    *
611    * @param parameterIndex
612    * the first parameter is 1, the second is 2, ...
613    * @param x
614    * the java reader which contains the UNICODE data
615    * @param length
616    * the number of characters in the stream
617    * @exception SQLException
618    * if a database access error occurs
619    * @since 1.2
620    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
621    * </a>
622    */

623   public void setCharacterStream(int parameterIndex, java.io.Reader JavaDoc reader, int length) throws SQLException JavaDoc
624   {
625     _underlyingSqlStatement.getStmt().setCharacterStream(parameterIndex, reader, length);
626   }
627
628   /**
629    * Sets the designated parameter to the given <code>REF(&lt;structured-type&gt;)</code>
630    * value.
631    *
632    * @param i
633    * the first parameter is 1, the second is 2, ...
634    * @param x
635    * an SQL <code>REF</code> value
636    * @exception SQLException
637    * if a database access error occurs
638    * @since 1.2
639    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
640    * </a>
641    */

642   public void setRef(int i, Ref JavaDoc x) throws SQLException JavaDoc
643   {
644     _underlyingSqlStatement.getStmt().setRef(i, x);
645   }
646
647   /**
648    * Sets the designated parameter to the given <code>Blob</code> object.
649    *
650    * @param i
651    * the first parameter is 1, the second is 2, ...
652    * @param x
653    * a <code>Blob</code> object that maps an SQL <code>BLOB</code>
654    * value
655    * @exception SQLException
656    * if a database access error occurs
657    * @since 1.2
658    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
659    * </a>
660    */

661   public void setBlob(int i, Blob JavaDoc x) throws SQLException JavaDoc
662   {
663     _underlyingSqlStatement.getStmt().setBlob(i, x);
664   }
665
666   /**
667    * Sets the designated parameter to the given <code>Clob</code> object.
668    *
669    * @param i
670    * the first parameter is 1, the second is 2, ...
671    * @param x
672    * a <code>Clob</code> object that maps an SQL <code>CLOB</code>
673    * value
674    * @exception SQLException
675    * if a database access error occurs
676    * @since 1.2
677    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
678    * </a>
679    */

680   public void setClob(int i, Clob JavaDoc x) throws SQLException JavaDoc
681   {
682     _underlyingSqlStatement.getStmt().setClob(i, x);
683   }
684
685   /**
686    * Sets the designated parameter to the given <code>Array</code> object.
687    * Sets an Array parameter.
688    *
689    * @param i
690    * the first parameter is 1, the second is 2, ...
691    * @param x
692    * an <code>Array</code> object that maps an SQL <code>ARRAY</code>
693    * value
694    * @exception SQLException
695    * if a database access error occurs
696    * @since 1.2
697    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
698    * </a>
699    */

700   public void setArray(int i, Array JavaDoc x) throws SQLException JavaDoc
701   {
702     _underlyingSqlStatement.getStmt().setArray(i, x);
703   }
704
705   /**
706    * Gets the number, types and properties of a <code>ResultSet</code>
707    * object's columns.
708    *
709    * @return the description of a <code>ResultSet</code> object's columns
710    * @exception SQLException
711    * if a database access error occurs
712    * @since 1.2
713    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
714    * </a>
715    */

716   public ResultSetMetaData JavaDoc getMetaData() throws SQLException JavaDoc
717   {
718     /** @todo: nog iomplementeren" */
719     return null;
720   }
721
722   /**
723    * Sets the designated parameter to the given <code>java.sql.Date</code>
724    * value, using the given <code>Calendar</code> object. The driver uses the
725    * <code>Calendar</code> object to construct an SQL <code>DATE</code>
726    * value, which the driver then sends to the database. With a a <code>Calendar</code>
727    * object, the driver can calculate the date taking into account a custom
728    * timezone. If no <code>Calendar</code> object is specified, the driver
729    * uses the default timezone, which is that of the virtual machine running
730    * the application.
731    *
732    * @param parameterIndex
733    * the first parameter is 1, the second is 2, ...
734    * @param x
735    * the parameter value
736    * @param cal
737    * the <code>Calendar</code> object the driver will use to
738    * construct the date
739    * @exception SQLException
740    * if a database access error occurs
741    * @since 1.2
742    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
743    * </a>
744    */

745   public void setDate(int parameterIndex, java.sql.Date JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc
746   {
747     _underlyingSqlStatement.getStmt().setDate(parameterIndex, x, cal);
748   }
749
750   /**
751    * Sets the designated parameter to the given <code>java.sql.Time</code>
752    * value, using the given <code>Calendar</code> object. The driver uses the
753    * <code>Calendar</code> object to construct an SQL <code>TIME</code>
754    * value, which the driver then sends to the database. With a a <code>Calendar</code>
755    * object, the driver can calculate the time taking into account a custom
756    * timezone. If no <code>Calendar</code> object is specified, the driver
757    * uses the default timezone, which is that of the virtual machine running
758    * the application.
759    *
760    * @param parameterIndex
761    * the first parameter is 1, the second is 2, ...
762    * @param x
763    * the parameter value
764    * @param cal
765    * the <code>Calendar</code> object the driver will use to
766    * construct the time
767    * @exception SQLException
768    * if a database access error occurs
769    * @since 1.2
770    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
771    * </a>
772    */

773   public void setTime(int parameterIndex, java.sql.Time JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc
774   {
775     _underlyingSqlStatement.getStmt().setTime(parameterIndex, x, cal);
776   }
777
778   /**
779    * Sets the designated parameter to the given <code>java.sql.Timestamp</code>
780    * value, using the given <code>Calendar</code> object. The driver uses the
781    * <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code>
782    * value, which the driver then sends to the database. With a a <code>Calendar</code>
783    * object, the driver can calculate the timestamp taking into account a
784    * custom timezone. If no <code>Calendar</code> object is specified, the
785    * driver uses the default timezone, which is that of the virtual machine
786    * running the application.
787    *
788    * @param parameterIndex
789    * the first parameter is 1, the second is 2, ...
790    * @param x
791    * the parameter value
792    * @param cal
793    * the <code>Calendar</code> object the driver will use to
794    * construct the timestamp
795    * @exception SQLException
796    * if a database access error occurs
797    * @since 1.2
798    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
799    * </a>
800    */

801   public void setTimestamp(int parameterIndex, java.sql.Timestamp JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc
802   {
803     _underlyingSqlStatement.getStmt().setTimestamp(parameterIndex, x, cal);
804   }
805
806   /**
807    * Sets the designated parameter to SQL <code>NULL</code>. This version of
808    * the method <code>setNull</code> should be used for user-defined types
809    * and REF type parameters. Examples of user-defined types include: STRUCT,
810    * DISTINCT, JAVA_OBJECT, and named array types.
811    *
812    * <P>
813    * <B>Note:</B> To be portable, applications must give the SQL type code
814    * and the fully-qualified SQL type name when specifying a NULL user-defined
815    * or REF parameter. In the case of a user-defined type the name is the type
816    * name of the parameter itself. For a REF parameter, the name is the type
817    * name of the referenced type. If a JDBC driver does not need the type code
818    * or type name information, it may ignore it.
819    *
820    * Although it is intended for user-defined and Ref parameters, this method
821    * may be used to set a null parameter of any JDBC type. If the parameter
822    * does not have a user-defined or REF type, the given typeName is ignored.
823    *
824    * @param parameterIndex
825    * the first parameter is 1, the second is 2, ...
826    * @param sqlType
827    * a value from <code>java.sql.Types</code>
828    * @param typeName
829    * the fully-qualified name of an SQL user-defined type; ignored
830    * if the parameter is not a user-defined type or REF
831    * @exception SQLException
832    * if a database access error occurs
833    * @since 1.2
834    * @see <a HREF="package-summary.html#2.0 API">What Is in the JDBC 2.0 API
835    * </a>
836    */

837   public void setNull(int paramIndex, int sqlType, String JavaDoc typeName) throws SQLException JavaDoc
838   {
839     _underlyingSqlStatement.getStmt().setNull(paramIndex, sqlType, typeName);
840   }
841
842   //////////////////////////Statement////////////////////////////
843
/**
844    * Executes an SQL statement that returns a single <code>ResultSet</code>
845    * object.
846    *
847    * @param sql
848    * typically this is a static SQL <code>SELECT</code> statement
849    * @return a <code>ResultSet</code> object that contains the data produced
850    * by the given query; never <code>null</code>
851    * @exception SQLException
852    * if a database access error occurs
853    */

854   public ResultSet JavaDoc executeQuery(String JavaDoc sql) throws SQLException JavaDoc
855   {
856     throw new SQLException JavaDoc("ps.executeQuery: this method is not implemented by the djeneric driver");
857   }
858
859   /**
860    * Executes an SQL <code>INSERT</code>,<code>UPDATE</code> or <code>DELETE</code>
861    * statement. In addition, SQL statements that return nothing, such as SQL
862    * DDL statements, can be executed.
863    *
864    * @param sql
865    * an SQL <code>INSERT</code>,<code>UPDATE</code> or <code>DELETE</code>
866    * statement or an SQL statement that returns nothing
867    * @return either the row count for <code>INSERT</code>,<code>UPDATE</code>
868    * or <code>DELETE</code> statements, or 0 for SQL statements that
869    * return nothing
870    * @exception SQLException
871    * if a database access error occurs
872    */

873   public int executeUpdate(String JavaDoc sql) throws SQLException JavaDoc
874   {
875     throw new SQLException JavaDoc("ps.executeUpdate: this method is not implemented by the djeneric driver");
876   }
877
878   /**
879    * Releases this <code>Statement</code> object's database and JDBC
880    * resources immediately instead of waiting for this to happen when it is
881    * automatically closed. It is generally good practice to release resources
882    * as soon as you are finished with them to avoid tying up database
883    * resources.
884    * <P>
885    * <B>Note:</B> A <code>Statement</code> object is automatically closed
886    * when it is garbage collected. When a <code>Statement</code> object is
887    * closed, its current <code>ResultSet</code> object, if one exists, is
888    * also closed.
889    *
890    * @exception SQLException
891    * if a database access error occurs
892    */

893   public void close() throws SQLException JavaDoc
894   {
895     _underlyingSqlStatement.close();
896     _connection.close(this);
897   }
898
899   protected void finalize()
900   {
901     try
902     {
903       super.finalize();
904       close();
905     }
906     catch (Throwable JavaDoc e)
907     {
908     }
909   }
910
911   //----------------------------------------------------------------------
912

913   /**
914    * Returns the maximum number of bytes allowed for any column value. This
915    * limit is the maximum number of bytes that can be returned for any column
916    * value. The limit applies only to <code>BINARY</code>,<code>VARBINARY</code>,
917    * <code>LONGVARBINARY</code>,<code>CHAR</code>,<code>VARCHAR</code>,
918    * and <code>LONGVARCHAR</code> columns. If the limit is exceeded, the
919    * excess data is silently discarded.
920    *
921    * @return the current max column size limit; zero means unlimited
922    * @exception SQLException
923    * if a database access error occurs
924    */

925   public int getMaxFieldSize() throws SQLException JavaDoc
926   {
927     return _underlyingSqlStatement.getStmt().getMaxFieldSize();
928   }
929
930   /**
931    * Sets the limit for the maximum number of bytes in a column to the given
932    * number of bytes. This is the maximum number of bytes that can be returned
933    * for any column value. This limit applies only to <code>BINARY</code>,
934    * <code>VARBINARY</code>,<code>LONGVARBINARY</code>,<code>CHAR</code>,
935    * <code>VARCHAR</code>, and <code>LONGVARCHAR</code> fields. If the
936    * limit is exceeded, the excess data is silently discarded. For maximum
937    * portability, use values greater than 256.
938    *
939    * @param max
940    * the new max column size limit; zero means unlimited
941    * @exception SQLException
942    * if a database access error occurs
943    */

944   public void setMaxFieldSize(int max) throws SQLException JavaDoc
945   {
946     _underlyingSqlStatement.getStmt().setMaxFieldSize(max);
947   }
948
949   /**
950    * Retrieves the maximum number of rows that a <code>ResultSet</code>
951    * object can contain. If the limit is exceeded, the excess rows are silently
952    * dropped.
953    *
954    * @return the current max row limit; zero means unlimited
955    * @exception SQLException
956    * if a database access error occurs
957    */

958   public int getMaxRows() throws SQLException JavaDoc
959   {
960     return _underlyingSqlStatement.getStmt().getMaxRows();
961   }
962
963   /**
964    * Sets the limit for the maximum number of rows that any <code>ResultSet</code>
965    * object can contain to the given number. If the limit is exceeded, the
966    * excess rows are silently dropped.
967    *
968    * @param max
969    * the new max rows limit; zero means unlimited
970    * @exception SQLException
971    * if a database access error occurs
972    */

973   public void setMaxRows(int max) throws SQLException JavaDoc
974   {
975     _underlyingSqlStatement.getStmt().setMaxRows(max);
976   }
977
978   /**
979    * Sets escape processing on or off. If escape scanning is on (the default),
980    * the driver will do escape substitution before sending the SQL to the
981    * database.
982    *
983    * Note: Since prepared statements have usually been parsed prior to making
984    * this call, disabling escape processing for prepared statements will have
985    * no effect.
986    *
987    * @param enable
988    * <code>true</code> to enable; <code>false</code> to disable
989    * @exception SQLException
990    * if a database access error occurs
991    */

992   public void setEscapeProcessing(boolean enable) throws SQLException JavaDoc
993   {
994     _underlyingSqlStatement.getStmt().setEscapeProcessing(enable);
995   }
996
997   /**
998    * Retrieves the number of seconds the driver will wait for a <code>Statement</code>
999    * object to execute. If the limit is exceeded, a <code>SQLException</code>
1000   * is thrown.
1001   *
1002   * @return the current query timeout limit in seconds; zero means unlimited
1003   * @exception SQLException
1004   * if a database access error occurs
1005   */

1006  public int getQueryTimeout() throws SQLException JavaDoc
1007  {
1008    return _underlyingSqlStatement.getStmt().getQueryTimeout();
1009  }
1010
1011  /**
1012   * Sets the number of seconds the driver will wait for a <code>Statement</code>
1013   * object to execute to the given number of seconds. If the limit is
1014   * exceeded, an <code>SQLException</code> is thrown.
1015   *
1016   * @param seconds
1017   * the new query timeout limit in seconds; zero means unlimited
1018   * @exception SQLException
1019   * if a database access error occurs
1020   */

1021  public void setQueryTimeout(int seconds) throws SQLException JavaDoc
1022  {
1023    _underlyingSqlStatement.getStmt().setQueryTimeout(seconds);
1024  }