KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > xml > XmlPreparedStatement


1 package org.webdocwf.util.xml;
2
3 import java.sql.PreparedStatement JavaDoc;
4 import java.sql.ResultSet JavaDoc;
5 import java.sql.SQLException JavaDoc;
6 import java.math.BigDecimal JavaDoc;
7 import java.sql.Date JavaDoc;
8 import java.sql.Time JavaDoc;
9 import java.sql.Timestamp JavaDoc;
10 import java.io.InputStream JavaDoc;
11 import java.io.Reader JavaDoc;
12 import java.sql.Ref JavaDoc;
13 import java.sql.Blob JavaDoc;
14 import java.sql.Clob JavaDoc;
15 import java.sql.Array JavaDoc;
16 import java.sql.ResultSetMetaData JavaDoc;
17 import java.util.Calendar JavaDoc;
18 import java.net.URL JavaDoc;
19 import java.sql.ParameterMetaData JavaDoc;
20 import java.sql.SQLWarning JavaDoc;
21 import java.sql.Connection JavaDoc;
22 import java.sql.DriverManager JavaDoc;
23 import java.io.File JavaDoc;
24 import java.util.*;
25
26 /**
27  * Class implements the JDBC PreparedStatement interface for the XmlJdbc driver.
28  *
29  * @author Zoran Milakovic
30  */

31
32 public class XmlPreparedStatement implements PreparedStatement JavaDoc {
33
34   private XmlConnection connection;
35   private Vector resultSets = new Vector();
36   private String JavaDoc sqlForPrepare = "";
37   private String JavaDoc sqlPrepared = "";
38   private int paramCount = 0;
39   private ArrayList parameters = new ArrayList();
40   private ArrayList binaryStreamParameters = new ArrayList();
41   private String JavaDoc fileName;
42   public static String JavaDoc PREPARE_SEPARATOR = "~@#NEXTPARAMETER#@~";
43
44   public XmlPreparedStatement(XmlConnection connection, String JavaDoc preparedSql) {
45     DriverManager.println("XmlJdbc - XmlStatement() - connection=" + connection);
46     this.sqlForPrepare = preparedSql;
47     this.sqlPrepared = preparedSql;
48     this.paramCount = countParameters(preparedSql);
49     for(int i = 0; i < paramCount; i++)
50       parameters.add("null");
51     this.connection = connection;
52     this.fileName = connection.getPath() + connection.getExtension();
53   }
54
55   private int countParameters(String JavaDoc sql) {
56     int count = 0;
57     int index = sql.indexOf(PREPARE_SEPARATOR);
58     while(index != -1) {
59       count++;
60       sql = sql.substring(index + 1);
61       index = sql.indexOf(PREPARE_SEPARATOR);
62     }
63     return count;
64   }
65
66   private boolean prepareSql() throws SQLException JavaDoc {
67     boolean retVal = true;
68
69     for(int i = 0; i < parameters.size(); i++) {
70       int index = sqlPrepared.indexOf(PREPARE_SEPARATOR);
71       if(index != -1) {
72         sqlPrepared = sqlPrepared.substring(0, index) +
73                       parameters.get(i) +
74                       sqlPrepared.substring(index + PREPARE_SEPARATOR.length());
75       }
76     }
77
78     if(sqlPrepared.indexOf(PREPARE_SEPARATOR) != -1)
79       throw new SQLException JavaDoc("All ? in prepared query has to be replaced with values.");
80     else if(parameters.size() < this.paramCount)
81       throw new SQLException JavaDoc(
82           "Number of setted parameters is less than number of parameters in statement.");
83     else if(parameters.size() > this.paramCount)
84       throw new SQLException JavaDoc(
85           "Number of setted parameters is greater than number of parameters in statement.");
86
87     return retVal;
88   }
89
90   /**
91    * Sets the maxFieldSize attribute of the XmlStatement object
92    *
93    * @param p0 The new maxFieldSize value
94    * @exception SQLException Description of Exception
95    * @since
96    */

97   public void setMaxFieldSize(int p0) throws SQLException JavaDoc {
98     throw new SQLException JavaDoc("Not Supported !");
99   }
100
101   /**
102    *Sets the maxRows attribute of the XmlStatement object
103    *
104    * @param p0 The new maxRows value
105    * @exception SQLException Description of Exception
106    * @since
107    */

108   public void setMaxRows(int p0) throws SQLException JavaDoc {
109     throw new SQLException JavaDoc("Not Supported !");
110   }
111
112   /**
113    *Sets the escapeProcessing attribute of the XmlStatement object
114    *
115    * @param p0 The new escapeProcessing value
116    * @exception SQLException Description of Exception
117    * @since
118    */

119   public void setEscapeProcessing(boolean p0) throws SQLException JavaDoc {
120     throw new SQLException JavaDoc("Not Supported !");
121   }
122
123   /**
124    *Sets the queryTimeout attribute of the XmlStatement object
125    *
126    * @param p0 The new queryTimeout value
127    * @exception SQLException Description of Exception
128    * @since
129    */

130   public void setQueryTimeout(int p0) throws SQLException JavaDoc {
131     throw new SQLException JavaDoc("Not Supported !");
132   }
133
134   /**
135    *Sets the cursorName attribute of the XmlStatement object
136    *
137    * @param p0 The new cursorName value
138    * @exception SQLException Description of Exception
139    * @since
140    */

141   public void setCursorName(String JavaDoc p0) throws SQLException JavaDoc {
142     throw new SQLException JavaDoc("Not Supported !");
143   }
144
145   /**
146    *Sets the fetchDirection attribute of the XmlStatement object
147    *
148    * @param p0 The new fetchDirection value
149    * @exception SQLException Description of Exception
150    * @since
151    */

152   public void setFetchDirection(int p0) throws SQLException JavaDoc {
153     throw new SQLException JavaDoc("Not Supported !");
154   }
155
156   /**
157    *Sets the fetchSize attribute of the XmlStatement object
158    *
159    * @param p0 The new fetchSize value
160    * @exception SQLException Description of Exception
161    * @since
162    */

163   public void setFetchSize(int p0) throws SQLException JavaDoc {
164     throw new SQLException JavaDoc("Not Supported !");
165   }
166
167   /**
168    *Gets the maxFieldSize attribute of the XmlStatement object
169    *
170    * @return The maxFieldSize value
171    * @exception SQLException Description of Exception
172    * @since
173    */

174   public int getMaxFieldSize() throws SQLException JavaDoc {
175     throw new SQLException JavaDoc("Not Supported !");
176   }
177
178   /**
179    *Gets the maxRows attribute of the XmlStatement object
180    *
181    * @return The maxRows value
182    * @exception SQLException Description of Exception
183    * @since
184    */

185   public int getMaxRows() throws SQLException JavaDoc {
186     throw new SQLException JavaDoc("Not Supported !");
187   }
188
189   /**
190    *Gets the queryTimeout attribute of the XmlStatement object
191    *
192    * @return The queryTimeout value
193    * @exception SQLException Description of Exception
194    * @since
195    */

196   public int getQueryTimeout() throws SQLException JavaDoc {
197     throw new SQLException JavaDoc("Not Supported !");
198   }
199
200   /**
201    *Gets the warnings attribute of the XmlStatement object
202    *
203    * @return The warnings value
204    * @exception SQLException Description of Exception
205    * @since
206    */

207   public SQLWarning JavaDoc getWarnings() throws SQLException JavaDoc {
208     throw new SQLException JavaDoc("Not Supported !");
209   }
210
211   /**
212    *Gets the resultSet attribute of the XmlStatement object
213    *
214    * @return The resultSet value
215    * @exception SQLException Description of Exception
216    * @since
217    */

218   public ResultSet JavaDoc getResultSet() throws SQLException JavaDoc {
219     throw new SQLException JavaDoc("Not Supported !");
220   }
221
222   /**
223    *Gets the updateCount attribute of the XmlStatement object
224    *
225    * @return The updateCount value
226    * @exception SQLException Description of Exception
227    * @since
228    */

229   public int getUpdateCount() throws SQLException JavaDoc {
230     throw new SQLException JavaDoc("Not Supported !");
231   }
232
233   /**
234    *Gets the moreResults attribute of the XmlStatement object
235    *
236    * @return The moreResults value
237    * @exception SQLException Description of Exception
238    * @since
239    */

240   public boolean getMoreResults() throws SQLException JavaDoc {
241     throw new SQLException JavaDoc("Not Supported !");
242   }
243
244   /**
245    *Gets the fetchDirection attribute of the XmlStatement object
246    *
247    * @return The fetchDirection value
248    * @exception SQLException Description of Exception
249    * @since
250    */

251   public int getFetchDirection() throws SQLException JavaDoc {
252     throw new SQLException JavaDoc("Not Supported !");
253   }
254
255   /**
256    *Gets the fetchSize attribute of the XmlStatement object
257    *
258    * @return The fetchSize value
259    * @exception SQLException Description of Exception
260    * @since
261    */

262   public int getFetchSize() throws SQLException JavaDoc {
263     throw new SQLException JavaDoc("Not Supported !");
264   }
265
266   /**
267    *Gets the resultSetConcurrency attribute of the XmlStatement object
268    *
269    * @return The resultSetConcurrency value
270    * @exception SQLException Description of Exception
271    * @since
272    */

273   public int getResultSetConcurrency() throws SQLException JavaDoc {
274     throw new SQLException JavaDoc("Not Supported !");
275   }
276
277   /**
278    *Gets the resultSetType attribute of the XmlStatement object
279    *
280    * @return The resultSetType value
281    * @exception SQLException Description of Exception
282    * @since
283    */

284   public int getResultSetType() throws SQLException JavaDoc {
285     throw new SQLException JavaDoc("Not Supported !");
286   }
287
288   /**
289    *Gets the connection attribute of the XmlStatement object
290    *
291    * @return The connection value
292    * @exception SQLException Description of Exception
293    * @since
294    */

295   public Connection JavaDoc getConnection() throws SQLException JavaDoc {
296     return connection;
297   }
298
299   public ResultSet JavaDoc executeQuery(String JavaDoc sql) throws SQLException JavaDoc {
300     DriverManager.println("XmlJdbc - XmlStatement:executeQuery() - sql= " + sql);
301     XmlWriter writer;
302     if(this.connection.getAutoCommit())
303       writer = new XmlWriter(fileName,true);
304     else
305       writer = new XmlWriter(fileName, false);
306     XmlSqlParser parser = new XmlSqlParser(this.fileName, this.connection.getAutoCommit() );
307     if( binaryStreamParameters.size() != 0 )
308           parser.setBinaryStreamList( binaryStreamParameters );
309     try {
310       parser.parse(sql);
311     }
312     catch(Exception JavaDoc e) {
313       throw new SQLException JavaDoc("Syntax Error. " + e.getMessage());
314     }
315     if(parser.sqlType.equals(parser.DROP_TABLE)) {
316       execute(sql);
317       return null;
318     }
319     if(parser.sqlType.equals(parser.DELETE)) {
320       executeUpdate(sql);
321       return null;
322     }
323     if(parser.sqlType.equals(parser.UPDATE)) {
324       executeUpdate(sql);
325       return null;
326     } else if(parser.sqlType.equals(parser.INSERT)) {
327       executeUpdate(sql);
328       return null;
329     } else if(parser.sqlType.equals(parser.CREATE_TABLE)) {
330       execute(sql);
331       return null;
332     } else if(parser.sqlType.equals(parser.SELECT)) {
333
334       String JavaDoc fileName = connection.getPath() + connection.getExtension();
335       File JavaDoc checkFile = new File JavaDoc(fileName);
336       XmlReader reader;
337       try {
338         reader = new XmlReader(fileName);
339         String JavaDoc[] xxx = parser.getColumnNames();
340         String JavaDoc[] yyy = (String JavaDoc[]) writer.getTableProperties(parser.getTableName()).get(0);
341         boolean isOK = true;
342         for(int i = 0; i < xxx.length; i++) {
343           out:
344               for(int j = 0; j < yyy.length; j++) {
345             if(xxx[i].equalsIgnoreCase(yyy[j])) {
346               isOK = true;
347               break out;
348             } else
349               isOK = false;
350           }
351           if(!isOK)
352             throw new SQLException JavaDoc("Column '" + xxx[i] + "' not found in table " +
353                 parser.getTableName());
354         }
355       }
356       catch(Exception JavaDoc e) {
357         throw new SQLException JavaDoc("Error reading data file. Message was: " + e);
358       }
359       XmlResultSet resultSet = new XmlResultSet(this, reader,
360                                parser.getTableName(), parser.getColumnNames(),
361                                parser.getWhereColumnNames(), parser.getWhereColumnValues());
362       resultSet.select();
363       return resultSet;
364     } else {
365       throw new SQLException JavaDoc("Syntax error.Not supported sql statement.");
366     }
367   }
368
369   /**
370    * Insert data into XML database
371    *
372    * @param sql Description of Parameter
373    * @return Description of the Returned Value
374    * @exception SQLException Description of Exception
375    * @since
376    */

377   public int executeUpdate(String JavaDoc sql) throws SQLException JavaDoc {
378     DriverManager.println("XmlJdbc - XmlStatement:executeUpdate() - sql= " + sql);
379     XmlSqlParser parser = new XmlSqlParser();
380     if( binaryStreamParameters.size() != 0 )
381           parser.setBinaryStreamList( binaryStreamParameters );
382     try {
383       parser.parse(sql);
384     }
385     catch(Exception JavaDoc e) {
386       throw new SQLException JavaDoc("Syntax Error. " + e.getMessage());
387     }
388     if(parser.sqlType.equals(parser.SELECT))
389       throw new SQLException JavaDoc("Not supported SELECT statement - use executeQuery() method");
390     else if(parser.sqlType.equals(parser.CREATE_TABLE)) {
391       throw new SQLException JavaDoc("Not supported CREATE_TABLE statement - use execute() method");
392     } else if(parser.sqlType.equals(parser.DROP_TABLE)) {
393       throw new SQLException JavaDoc("Not supported DROP_TABLE statement - use execute() method");
394     } else if(parser.sqlType.equals(parser.INSERT)) {
395       String JavaDoc fileName = connection.getPath() + connection.getExtension();
396       XmlWriter writeXml;
397       try {
398         if(this.connection.getAutoCommit())
399           writeXml = new XmlWriter(fileName,true);
400         else
401           writeXml = new XmlWriter(fileName, false);
402         ArrayList properties = writeXml.getTableProperties(parser.tableName);
403         //check for existance of columns
404
String JavaDoc[] xxx = parser.getColumnNames();
405         String JavaDoc[] yyy = (String JavaDoc[]) properties.get(0);
406         boolean isOK = true;
407         for(int i = 0; i < xxx.length; i++) {
408           if(!xxx[i].endsWith("*")) {
409             out:
410                 for(int j = 0; j < yyy.length; j++) {
411               if(xxx[i].equalsIgnoreCase(yyy[j])) {
412                 isOK = true;
413                 break out;
414               } else
415                 isOK = false;
416             }
417             if(!isOK)
418               throw new SQLException JavaDoc("Column '" + xxx[i] + "' not found in table " +
419                   parser.getTableName());
420           }
421         }
422         //check if NOTNULL columns is set
423
if(!properties.get(1).toString().equalsIgnoreCase("NO CREATE TABLE")) {
424           yyy = parser.getColumnNames();
425           xxx = (String JavaDoc[]) writeXml.getTableProperties(parser.tableName).get(2);
426           isOK = true;
427           for(int i = 0; i < xxx.length; i++) {
428             out:
429                 for(int j = 0; j < yyy.length; j++) {
430               if(xxx[i].equalsIgnoreCase(yyy[j])) {
431                 isOK = true;
432                 break out;
433               } else
434                 isOK = false;
435             }
436             if(!isOK)
437               throw new SQLException JavaDoc("Column '" + xxx[i] + "' can not be NULL.");
438           }
439         }
440         writeXml.insert(parser.getTableName(), parser.getColumnNames(), parser.getColumnValues());
441       }
442       catch(Exception JavaDoc e) {
443         throw new SQLException JavaDoc("Error reading data file. Message was: " + e);
444       }
445
446     } else if(parser.sqlType.equals(parser.UPDATE)) {
447       String JavaDoc fileName = connection.getPath() + connection.getExtension();
448       XmlWriter writeXml;
449       try {
450         if(this.connection.getAutoCommit())
451           writeXml = new XmlWriter(fileName,true);
452         else
453           writeXml = new XmlWriter(fileName, false);
454         String JavaDoc[] xxx = parser.getColumnNames();
455         String JavaDoc[] yyy = (String JavaDoc[]) writeXml.getTableProperties(parser.tableName).get(0);
456         boolean isOK = true;
457         for(int i = 0; i < xxx.length; i++) {
458           if(!xxx[i].endsWith("*")) {
459             out:
460                 for(int j = 0; j < yyy.length; j++) {
461               if(xxx[i].equalsIgnoreCase(yyy[j])) {
462                 isOK = true;
463                 break out;
464               } else
465                 isOK = false;
466             }
467             if(!isOK)
468               throw new SQLException JavaDoc("Column '" + xxx[i] + "' not found in table " +
469                   parser.getTableName());
470           }
471         }
472         writeXml.update(parser.getTableName(), parser.getColumnNames(), parser.getColumnValues(),
473             parser.getWhereColumnNames(), parser.getWhereColumnValues());
474       }
475       catch(Exception JavaDoc e) {
476         throw new SQLException JavaDoc("Error reading data file. Message was: " + e);
477       }
478
479     } else if(parser.sqlType.equals(parser.DELETE)) {
480       String JavaDoc fileName = connection.getPath() + connection.getExtension();
481       XmlWriter writeXml;
482       try {
483         if(this.connection.getAutoCommit())
484           writeXml = new XmlWriter(fileName,true);
485         else
486           writeXml = new XmlWriter(fileName, false);
487         String JavaDoc[] xxx = parser.getWhereColumnNames();
488         String JavaDoc[] yyy = (String JavaDoc[]) writeXml.getTableProperties(parser.tableName).get(0);
489         boolean isOK = true;
490         for(int i = 0; i < xxx.length; i++) {
491           if(!xxx[i].endsWith("*")) {
492             out:
493                 for(int j = 0; j < yyy.length; j++) {
494               if(xxx[i].equalsIgnoreCase(yyy[j])) {
495                 isOK = true;
496                 break out;
497               } else
498                 isOK = false;
499             }
500             if(!isOK)
501               throw new SQLException JavaDoc("Column '" + xxx[i] + "' not found in table " +
502                   parser.getTableName());
503           }
504         }
505         writeXml.delete(parser.getTableName(), parser.getWhereColumnNames(),
506             parser.getWhereColumnValues());
507       }
508       catch(Exception JavaDoc e) {
509         throw new SQLException JavaDoc("Error reading data file. Message was: " + e);
510       }
511
512     } else if(parser.sqlType.equals(parser.DROP_TABLE)) {
513     }
514     return 0;
515
516   }
517
518   /**
519    * Releases this <code>Statement</code> object's database
520    * and JDBC resources immediately instead of waiting for
521    * this to happen when it is automatically closed.
522    * It is generally good practice to release resources as soon as
523    * you are finished with them to avoid tying up database
524    * resources.
525    * <P>
526    * Calling the method <code>close</code> on a <code>Statement</code>
527    * object that is already closed has no effect.
528    * <P>
529    * <B>Note:</B> A <code>Statement</code> object is automatically closed
530    * when it is garbage collected. When a <code>Statement</code> object is
531    * closed, its current <code>ResultSet</code> object, if one exists, is
532    * also closed.
533    *
534    * @exception SQLException if a database access error occurs
535    */

536   public void close() throws SQLException JavaDoc {
537   // close all result sets
538
}
539
540   /**
541    *Description of the Method
542    *
543    * @exception SQLException Description of Exception
544    * @since
545    */

546   public void cancel() throws SQLException JavaDoc {
547     throw new SQLException JavaDoc("Not Supported !");
548   }
549
550   /**
551    *Description of the Method
552    *
553    * @exception SQLException Description of Exception
554    * @since
555    */

556   public void clearWarnings() throws SQLException JavaDoc {
557     throw new SQLException JavaDoc("Not Supported !");
558   }
559
560   /**
561    *Description of the Method
562    *
563    * @param sql Description of Parameter
564    * @return Description of the Returned Value
565    * @exception SQLException Description of Exception
566    * @since
567    */

568   public boolean execute(String JavaDoc sql) throws SQLException JavaDoc {
569     XmlWriter writeXml;
570     if(this.connection.getAutoCommit())
571       writeXml = new XmlWriter(fileName,true);
572     else
573       writeXml = new XmlWriter(fileName, false);
574     XmlSqlParser parser = new XmlSqlParser(this.fileName, this.connection.getAutoCommit() );
575     if( binaryStreamParameters.size() != 0 )
576           parser.setBinaryStreamList( binaryStreamParameters );
577     try {
578       parser.parse(sql);
579     }
580     catch(Exception JavaDoc e) {
581       throw new SQLException JavaDoc("Syntax Error. " + e.getMessage());
582     }
583     if(parser.sqlType.equals(parser.SELECT))
584       throw new SQLException JavaDoc("Use executeQuery() for SELECT statement");
585     else if(parser.sqlType.equals(parser.UPDATE))
586       executeUpdate(sql);
587     else if(parser.sqlType.equals(parser.INSERT))
588       executeUpdate(sql);
589     else if(parser.sqlType.equals(parser.DELETE))
590       executeUpdate(sql);
591     else if(parser.sqlType.equals(parser.CREATE_TABLE)) {
592       String JavaDoc fileName = connection.getPath() + connection.getExtension();
593       try {
594         writeXml.createTable(parser.getSqlStatement(), parser.getTableName());
595       }
596       catch(Exception JavaDoc e) {
597         throw new SQLException JavaDoc("Error reading data file. Message was: " + e);
598       }
599     } else if(parser.sqlType.equals(parser.DROP_TABLE)) {
600       String JavaDoc fileName = connection.getPath() + connection.getExtension();
601       try {
602         writeXml.dropTable(parser.getTableName());
603       }
604       catch(Exception JavaDoc e) {
605         throw new SQLException JavaDoc("Error reading data file. Message was: " + e);
606       }
607     }
608     return true;
609
610   }
611
612   /**
613    * Set String as parameter in sql statement.
614    * @param parameterIndex
615    * @param value
616    * @throws SQLException
617    */

618   public void setString(int parameterIndex, String JavaDoc value) throws SQLException JavaDoc {
619     if( value == null )
620       value = "null";
621     value = Utils.replaceAll( value, "'", XmlSqlParser.quoteEscape);
622
623 XmlDriver.log("XmlPreparedStatement.setString(), value = "+value);
624
625     parameters.set(parameterIndex - 1, "'" + value + "'");
626   }
627
628   /**
629    *
630    * @param parameterIndex
631    * @param value
632    * @throws SQLException
633    */

634   public void setBinaryStream(int parameterIndex, InputStream JavaDoc value,
635       int length) throws SQLException JavaDoc {
636     throw new SQLException JavaDoc("Not Supported !");
637   }
638
639   /**
640    *
641    * @param parameterIndex
642    * @param value
643    * @throws SQLException
644    */

645   public void setBytes(int parameterIndex, byte[] value) throws SQLException JavaDoc {
646     binaryStreamParameters.add(Utils.bytesToHexString(value));
647     String JavaDoc paramName = XmlSqlParser.BINARY_STREAM_OBJECT+binaryStreamParameters.size();
648     parameters.set(parameterIndex-1, paramName);
649   }
650
651
652   /**
653    *
654    * @param parameterIndex
655    * @param value
656    * @throws SQLException
657    */

658   public void setBlob(int parameterIndex, Blob JavaDoc value) throws SQLException JavaDoc {
659     throw new SQLException JavaDoc("Not Supported !");
660   }
661
662   /**
663    * Adds a feature to the Batch attribute of the XmlStatement object
664    *
665    * @param p0 The feature to be added to the Batch attribute
666    * @exception SQLException Description of Exception
667    * @since
668    */

669   public void addBatch(String JavaDoc p0) throws SQLException JavaDoc {
670     throw new SQLException JavaDoc("Not Supported !");
671   }
672
673   /**
674    *Description of the Method
675    *
676    * @exception SQLException Description of Exception
677    * @since
678    */

679   public void clearBatch() throws SQLException JavaDoc {
680     throw new SQLException JavaDoc("Not Supported !");
681   }
682
683   /**
684    *Description of the Method
685    *
686    * @return Description of the Returned Value
687    * @exception SQLException Description of Exception
688    * @since
689    */

690   public int[] executeBatch() throws SQLException JavaDoc {
691     throw new SQLException JavaDoc("Not Supported !");
692   }
693
694   //---------------------------------------------------------------------
695
// JDBC 3.0
696
//---------------------------------------------------------------------
697

698   public boolean getMoreResults(int current) throws SQLException JavaDoc {
699     throw new UnsupportedOperationException JavaDoc("Statement.getMoreResults(int) unsupported");
700   }
701
702   public ResultSet JavaDoc getGeneratedKeys() throws SQLException JavaDoc {
703     throw new UnsupportedOperationException JavaDoc("Statement.getGeneratedKeys() unsupported");
704   }
705
706   public int executeUpdate(String JavaDoc sql, int autoGeneratedKeys) throws SQLException JavaDoc {
707     throw new UnsupportedOperationException JavaDoc("Statement.executeUpdate(String,int) unsupported");
708   }
709
710   public int executeUpdate(String JavaDoc sql, int[] columnIndexes) throws SQLException JavaDoc {
711     throw new UnsupportedOperationException JavaDoc("Statement.executeUpdate(String,int[]) unsupported");
712   }
713
714   public int executeUpdate(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException JavaDoc {
715     throw new UnsupportedOperationException JavaDoc("Statement.executeUpdate(String,String[]) unsupported");
716   }
717
718   public boolean execute(String JavaDoc sql, int autoGeneratedKeys) throws SQLException JavaDoc {
719     throw new UnsupportedOperationException JavaDoc("Statement.execute(String,int) unsupported");
720   }
721
722   public boolean execute(String JavaDoc sql, int[] columnIndexes) throws SQLException JavaDoc {
723     throw new UnsupportedOperationException JavaDoc("Statement.execute(String,int[]) unsupported");
724   }
725
726   public boolean execute(String JavaDoc sql, String JavaDoc[] columnNames) throws SQLException JavaDoc {
727     throw new UnsupportedOperationException JavaDoc("Statement.execute(String,String[]) unsupported");
728   }
729
730   public int getResultSetHoldability() throws SQLException JavaDoc {
731     throw new UnsupportedOperationException JavaDoc("Statement.getResultSetHoldability() unsupported");
732   }
733
734   public ResultSet JavaDoc executeQuery() throws SQLException JavaDoc {
735     if(!prepareSql())
736       throw new SQLException JavaDoc("Error with prepared statement !");
737     return executeQuery(this.sqlPrepared);
738
739   }
740
741   public int executeUpdate() throws SQLException JavaDoc {
742     if(!prepareSql())
743       throw new SQLException JavaDoc("Error with prepared statement !");
744     executeUpdate(this.sqlPrepared);
745     return 0;
746   }
747
748   public void setNull(int parameterIndex, int sqlType) throws SQLException JavaDoc {
749     this.setString(parameterIndex, "null" );
750   }
751
752   public void setBoolean(int parameterIndex, boolean value) throws SQLException JavaDoc {
753     this.setString(parameterIndex, String.valueOf(value) );
754   }
755
756   public void setByte(int parameterIndex, byte value) throws SQLException JavaDoc {
757     this.setString(parameterIndex, String.valueOf(value) );
758   }
759
760   public void setShort(int parameterIndex, short value) throws SQLException JavaDoc {
761     this.setString(parameterIndex, String.valueOf(value) );
762   }
763
764   public void setInt(int parameterIndex, int value) throws SQLException JavaDoc {
765     this.setString(parameterIndex, String.valueOf(value) );
766   }
767
768   public void setLong(int parameterIndex, long value) throws SQLException JavaDoc {
769     this.setString(parameterIndex, String.valueOf(value) );
770   }
771
772   public void setFloat(int parameterIndex, float value) throws SQLException JavaDoc {
773     this.setString(parameterIndex, String.valueOf(value) );
774   }
775
776   public void setDouble(int parameterIndex, double value) throws SQLException JavaDoc {
777     this.setString(parameterIndex, String.valueOf(value) );
778   }
779
780   public void setBigDecimal(int parameterIndex, BigDecimal JavaDoc value) throws SQLException JavaDoc {
781       if(value == null) {
782           this.setString( parameterIndex, value.toString() );
783       } else {
784           this.setString( parameterIndex, "" );
785       }
786   }
787
788   public void setDate(int parameterIndex, Date JavaDoc value) throws SQLException JavaDoc {
789       if(value == null) {
790           this.setString( parameterIndex, value.toString() );
791       } else {
792           this.setString( parameterIndex, "" );
793       }
794   }
795   
796   public void setTime(int parameterIndex, Time JavaDoc value) throws SQLException JavaDoc {
797       if(value == null) {
798           this.setString( parameterIndex, value.toString() );
799       } else {
800           this.setString( parameterIndex, "" );
801       }
802   }
803   
804   public void setTimestamp(int parameterIndex, Timestamp JavaDoc value) throws SQLException JavaDoc {
805       if(value == null) {
806           this.setString( parameterIndex, value.toString() );
807       } else {
808           this.setString( parameterIndex, "" );
809       }
810   }
811
812   public void setAsciiStream(int parameterIndex, InputStream JavaDoc x, int length) throws SQLException JavaDoc {
813     /**@todo Implement this java.sql.PreparedStatement method*/
814     throw new java.lang.UnsupportedOperationException JavaDoc(
815         "Method setAsciiStream() not yet implemented.");
816   }
817
818   public void setUnicodeStream(int parameterIndex, InputStream JavaDoc x, int length) throws SQLException JavaDoc {
819     /**@todo Implement this java.sql.PreparedStatement method*/
820     throw new java.lang.UnsupportedOperationException JavaDoc(
821         "Method setUnicodeStream() not yet implemented.");
822   }
823
824   public void clearParameters() throws SQLException JavaDoc {
825     this.sqlPrepared = this.sqlForPrepare;
826 // this.parameters.clear();
827
for(int i = 0; i < parameters.size(); i++)
828       parameters.set(i, null);
829     this.binaryStreamParameters.clear();
830   }
831
832   public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType,
833       int scale) throws SQLException JavaDoc {
834     /**@todo Implement this java.sql.PreparedStatement method*/
835     throw new java.lang.UnsupportedOperationException JavaDoc("Method setObject() not yet implemented.");
836   }
837
838   public void setObject(int parameterIndex, Object JavaDoc x, int targetSqlType) throws SQLException JavaDoc {
839     /**@todo Implement this java.sql.PreparedStatement method*/
840     throw new java.lang.UnsupportedOperationException JavaDoc("Method setObject() not yet implemented.");
841   }
842
843   public void setObject(int parameterIndex, Object JavaDoc x) throws SQLException JavaDoc {
844     if(x == null)
845       x = new String JavaDoc("null");
846     setString(parameterIndex, x.toString());
847   }
848
849   public boolean execute() throws SQLException JavaDoc {
850     /**@todo Implement this java.sql.PreparedStatement method*/
851     throw new java.lang.UnsupportedOperationException JavaDoc("Method execute() not yet implemented.");
852   }
853
854   public void addBatch() throws SQLException JavaDoc {
855     /**@todo Implement this java.sql.PreparedStatement method*/
856     throw new java.lang.UnsupportedOperationException JavaDoc("Method addBatch() not yet implemented.");
857   }
858
859   public void setCharacterStream(int parameterIndex, Reader JavaDoc reader, int length) throws SQLException JavaDoc {
860     /**@todo Implement this java.sql.PreparedStatement method*/
861     throw new java.lang.UnsupportedOperationException JavaDoc(
862         "Method setCharacterStream() not yet implemented.");
863   }
864
865   public void setRef(int i, Ref JavaDoc x) throws SQLException JavaDoc {
866     /**@todo Implement this java.sql.PreparedStatement method*/
867     throw new java.lang.UnsupportedOperationException JavaDoc("Method setRef() not yet implemented.");
868   }
869
870   public void setClob(int i, Clob JavaDoc x) throws SQLException JavaDoc {
871     /**@todo Implement this java.sql.PreparedStatement method*/
872     throw new java.lang.UnsupportedOperationException JavaDoc("Method setClob() not yet implemented.");
873   }
874
875   public void setArray(int i, Array JavaDoc x) throws SQLException JavaDoc {
876     /**@todo Implement this java.sql.PreparedStatement method*/
877     throw new java.lang.UnsupportedOperationException JavaDoc("Method setArray() not yet implemented.");
878   }
879
880   public ResultSetMetaData JavaDoc getMetaData() throws SQLException JavaDoc {
881     /**@todo Implement this java.sql.PreparedStatement method*/
882     throw new java.lang.UnsupportedOperationException JavaDoc("Method getMetaData() not yet implemented.");
883   }
884
885   public void setDate(int parameterIndex, Date JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
886     /**@todo Implement this java.sql.PreparedStatement method*/
887     throw new java.lang.UnsupportedOperationException JavaDoc("Method setDate() not yet implemented.");
888   }
889
890   public void setTime(int parameterIndex, Time JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
891     /**@todo Implement this java.sql.PreparedStatement method*/
892     throw new java.lang.UnsupportedOperationException JavaDoc("Method setTime() not yet implemented.");
893   }
894
895   public void setTimestamp(int parameterIndex, Timestamp JavaDoc x, Calendar JavaDoc cal) throws SQLException JavaDoc {
896     /**@todo Implement this java.sql.PreparedStatement method*/
897     throw new java.lang.UnsupportedOperationException JavaDoc("Method setTimestamp() not yet implemented.");
898   }
899
900   public void setNull(int paramIndex, int sqlType, String JavaDoc typeName) throws SQLException JavaDoc {
901     this.setString(paramIndex, "null" );
902   }
903
904   public void setURL(int parameterIndex, URL JavaDoc x) throws SQLException JavaDoc {
905     /**@todo Implement this java.sql.PreparedStatement method*/
906     throw new java.lang.UnsupportedOperationException JavaDoc("Method setURL() not yet implemented.");
907   }
908
909   public ParameterMetaData JavaDoc getParameterMetaData() throws SQLException JavaDoc {
910     /**@todo Implement this java.sql.PreparedStatement method*/
911     throw new java.lang.UnsupportedOperationException JavaDoc(
912         "Method getParameterMetaData() not yet implemented.");
913   }
914
915 }
Popular Tags