1 package org.webdocwf.util.xml;
2
3 import java.sql.PreparedStatement;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.math.BigDecimal;
7 import java.sql.Date;
8 import java.sql.Time;
9 import java.sql.Timestamp;
10 import java.io.InputStream;
11 import java.io.Reader;
12 import java.sql.Ref;
13 import java.sql.Blob;
14 import java.sql.Clob;
15 import java.sql.Array;
16 import java.sql.ResultSetMetaData;
17 import java.util.Calendar;
18 import java.net.URL;
19 import java.sql.ParameterMetaData;
20 import java.sql.SQLWarning;
21 import java.sql.Connection;
22 import java.sql.DriverManager;
23 import java.io.File;
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 {
33
34 private XmlConnection connection;
35 private Vector resultSets = new Vector();
36 private String sqlForPrepare = "";
37 private String sqlPrepared = "";
38 private int paramCount = 0;
39 private ArrayList parameters = new ArrayList();
40 private ArrayList binaryStreamParameters = new ArrayList();
41 private String fileName;
42 public static String PREPARE_SEPARATOR = "~@#NEXTPARAMETER#@~";
43
44 public XmlPreparedStatement(XmlConnection connection, String 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 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 {
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("All ? in prepared query has to be replaced with values.");
80 else if(parameters.size() < this.paramCount)
81 throw new SQLException(
82 "Number of setted parameters is less than number of parameters in statement.");
83 else if(parameters.size() > this.paramCount)
84 throw new SQLException(
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 {
98 throw new SQLException("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 {
109 throw new SQLException("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 {
120 throw new SQLException("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 {
131 throw new SQLException("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 p0) throws SQLException {
142 throw new SQLException("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 {
153 throw new SQLException("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 {
164 throw new SQLException("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 {
175 throw new SQLException("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 {
186 throw new SQLException("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 {
197 throw new SQLException("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 getWarnings() throws SQLException {
208 throw new SQLException("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 getResultSet() throws SQLException {
219 throw new SQLException("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 {
230 throw new SQLException("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 {
241 throw new SQLException("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 {
252 throw new SQLException("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 {
263 throw new SQLException("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 {
274 throw new SQLException("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 {
285 throw new SQLException("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 getConnection() throws SQLException {
296 return connection;
297 }
298
299 public ResultSet executeQuery(String sql) throws SQLException {
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 e) {
313 throw new SQLException("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 fileName = connection.getPath() + connection.getExtension();
335 File checkFile = new File(fileName);
336 XmlReader reader;
337 try {
338 reader = new XmlReader(fileName);
339 String[] xxx = parser.getColumnNames();
340 String[] yyy = (String[]) 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("Column '" + xxx[i] + "' not found in table " +
353 parser.getTableName());
354 }
355 }
356 catch(Exception e) {
357 throw new SQLException("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("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 sql) throws SQLException {
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 e) {
386 throw new SQLException("Syntax Error. " + e.getMessage());
387 }
388 if(parser.sqlType.equals(parser.SELECT))
389 throw new SQLException("Not supported SELECT statement - use executeQuery() method");
390 else if(parser.sqlType.equals(parser.CREATE_TABLE)) {
391 throw new SQLException("Not supported CREATE_TABLE statement - use execute() method");
392 } else if(parser.sqlType.equals(parser.DROP_TABLE)) {
393 throw new SQLException("Not supported DROP_TABLE statement - use execute() method");
394 } else if(parser.sqlType.equals(parser.INSERT)) {
395 String 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[] xxx = parser.getColumnNames();
405 String[] yyy = (String[]) 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("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[]) 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("Column '" + xxx[i] + "' can not be NULL.");
438 }
439 }
440 writeXml.insert(parser.getTableName(), parser.getColumnNames(), parser.getColumnValues());
441 }
442 catch(Exception e) {
443 throw new SQLException("Error reading data file. Message was: " + e);
444 }
445
446 } else if(parser.sqlType.equals(parser.UPDATE)) {
447 String 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[] xxx = parser.getColumnNames();
455 String[] yyy = (String[]) 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("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 e) {
476 throw new SQLException("Error reading data file. Message was: " + e);
477 }
478
479 } else if(parser.sqlType.equals(parser.DELETE)) {
480 String 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[] xxx = parser.getWhereColumnNames();
488 String[] yyy = (String[]) 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("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 e) {
509 throw new SQLException("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 {
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 {
547 throw new SQLException("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 {
557 throw new SQLException("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 sql) throws SQLException {
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 e) {
581 throw new SQLException("Syntax Error. " + e.getMessage());
582 }
583 if(parser.sqlType.equals(parser.SELECT))
584 throw new SQLException("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 fileName = connection.getPath() + connection.getExtension();
593 try {
594 writeXml.createTable(parser.getSqlStatement(), parser.getTableName());
595 }
596 catch(Exception e) {
597 throw new SQLException("Error reading data file. Message was: " + e);
598 }
599 } else if(parser.sqlType.equals(parser.DROP_TABLE)) {
600 String fileName = connection.getPath() + connection.getExtension();
601 try {
602 writeXml.dropTable(parser.getTableName());
603 }
604 catch(Exception e) {
605 throw new SQLException("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 value) throws SQLException {
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 value,
635 int length) throws SQLException {
636 throw new SQLException("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 {
646 binaryStreamParameters.add(Utils.bytesToHexString(value));
647 String 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 value) throws SQLException {
659 throw new SQLException("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 p0) throws SQLException {
670 throw new SQLException("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 {
680 throw new SQLException("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 {
691 throw new SQLException("Not Supported !");
692 }
693
694 //---------------------------------------------------------------------
695 // JDBC 3.0
696 //---------------------------------------------------------------------
697
698 public boolean getMoreResults(int current) throws SQLException {
699 throw new UnsupportedOperationException("Statement.getMoreResults(int) unsupported");
700 }
701
702 public ResultSet getGeneratedKeys() throws SQLException {
703 throw new UnsupportedOperationException("Statement.getGeneratedKeys() unsupported");
704 }
705
706 public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
707 throw new UnsupportedOperationException("Statement.executeUpdate(String,int) unsupported");
708 }
709
710 public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
711 throw new UnsupportedOperationException("Statement.executeUpdate(String,int[]) unsupported");
712 }
713
714 public int executeUpdate(String sql, String[] columnNames) throws SQLException {
715 throw new UnsupportedOperationException("Statement.executeUpdate(String,String[]) unsupported");
716 }
717
718 public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
719 throw new UnsupportedOperationException("Statement.execute(String,int) unsupported");
720 }
721
722 public boolean execute(String sql, int[] columnIndexes) throws SQLException {
723 throw new UnsupportedOperationException("Statement.execute(String,int[]) unsupported");
724 }
725
726 public boolean execute(String sql, String[] columnNames) throws SQLException {
727 throw new UnsupportedOperationException("Statement.execute(String,String[]) unsupported");
728 }
729
730 public int getResultSetHoldability() throws SQLException {
731 throw new UnsupportedOperationException("Statement.getResultSetHoldability() unsupported");
732 }
733
734 public ResultSet executeQuery() throws SQLException {
735 if(!prepareSql())
736 throw new SQLException("Error with prepared statement !");
737 return executeQuery(this.sqlPrepared);
738
739 }
740
741 public int executeUpdate() throws SQLException {
742 if(!prepareSql())
743 throw new SQLException("Error with prepared statement !");
744 executeUpdate(this.sqlPrepared);
745 return 0;
746 }
747
748 public void setNull(int parameterIndex, int sqlType) throws SQLException {
749 this.setString(parameterIndex, "null" );
750 }
751
752 public void setBoolean(int parameterIndex, boolean value) throws SQLException {
753 this.setString(parameterIndex, String.valueOf(value) );
754 }
755
756 public void setByte(int parameterIndex, byte value) throws SQLException {
757 this.setString(parameterIndex, String.valueOf(value) );
758 }
759
760 public void setShort(int parameterIndex, short value) throws SQLException {
761 this.setString(parameterIndex, String.valueOf(value) );
762 }
763
764 public void setInt(int parameterIndex, int value) throws SQLException {
765 this.setString(parameterIndex, String.valueOf(value) );
766 }
767
768 public void setLong(int parameterIndex, long value) throws SQLException {
769 this.setString(parameterIndex, String.valueOf(value) );
770 }
771
772 public void setFloat(int parameterIndex, float value) throws SQLException {
773 this.setString(parameterIndex, String.valueOf(value) );
774 }
775
776 public void setDouble(int parameterIndex, double value) throws SQLException {
777 this.setString(parameterIndex, String.valueOf(value) );
778 }
779
780 public void setBigDecimal(int parameterIndex, BigDecimal value) throws SQLException {
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 value) throws SQLException {
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 value) throws SQLException {
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 value) throws SQLException {
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 x, int length) throws SQLException {
813 /***@todo Implement this java.sql.PreparedStatement method*/
814 throw new java.lang.UnsupportedOperationException(
815 "Method setAsciiStream() not yet implemented.");
816 }
817
818 public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException {
819 /***@todo Implement this java.sql.PreparedStatement method*/
820 throw new java.lang.UnsupportedOperationException(
821 "Method setUnicodeStream() not yet implemented.");
822 }
823
824 public void clearParameters() throws SQLException {
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 x, int targetSqlType,
833 int scale) throws SQLException {
834 /***@todo Implement this java.sql.PreparedStatement method*/
835 throw new java.lang.UnsupportedOperationException("Method setObject() not yet implemented.");
836 }
837
838 public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException {
839 /***@todo Implement this java.sql.PreparedStatement method*/
840 throw new java.lang.UnsupportedOperationException("Method setObject() not yet implemented.");
841 }
842
843 public void setObject(int parameterIndex, Object x) throws SQLException {
844 if(x == null)
845 x = new String("null");
846 setString(parameterIndex, x.toString());
847 }
848
849 public boolean execute() throws SQLException {
850 /***@todo Implement this java.sql.PreparedStatement method*/
851 throw new java.lang.UnsupportedOperationException("Method execute() not yet implemented.");
852 }
853
854 public void addBatch() throws SQLException {
855 /***@todo Implement this java.sql.PreparedStatement method*/
856 throw new java.lang.UnsupportedOperationException("Method addBatch() not yet implemented.");
857 }
858
859 public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
860 /***@todo Implement this java.sql.PreparedStatement method*/
861 throw new java.lang.UnsupportedOperationException(
862 "Method setCharacterStream() not yet implemented.");
863 }
864
865 public void setRef(int i, Ref x) throws SQLException {
866 /***@todo Implement this java.sql.PreparedStatement method*/
867 throw new java.lang.UnsupportedOperationException("Method setRef() not yet implemented.");
868 }
869
870 public void setClob(int i, Clob x) throws SQLException {
871 /***@todo Implement this java.sql.PreparedStatement method*/
872 throw new java.lang.UnsupportedOperationException("Method setClob() not yet implemented.");
873 }
874
875 public void setArray(int i, Array x) throws SQLException {
876 /***@todo Implement this java.sql.PreparedStatement method*/
877 throw new java.lang.UnsupportedOperationException("Method setArray() not yet implemented.");
878 }
879
880 public ResultSetMetaData getMetaData() throws SQLException {
881 /***@todo Implement this java.sql.PreparedStatement method*/
882 throw new java.lang.UnsupportedOperationException("Method getMetaData() not yet implemented.");
883 }
884
885 public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
886 /***@todo Implement this java.sql.PreparedStatement method*/
887 throw new java.lang.UnsupportedOperationException("Method setDate() not yet implemented.");
888 }
889
890 public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
891 /***@todo Implement this java.sql.PreparedStatement method*/
892 throw new java.lang.UnsupportedOperationException("Method setTime() not yet implemented.");
893 }
894
895 public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
896 /***@todo Implement this java.sql.PreparedStatement method*/
897 throw new java.lang.UnsupportedOperationException("Method setTimestamp() not yet implemented.");
898 }
899
900 public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
901 this.setString(paramIndex, "null" );
902 }
903
904 public void setURL(int parameterIndex, URL x) throws SQLException {
905 /***@todo Implement this java.sql.PreparedStatement method*/
906 throw new java.lang.UnsupportedOperationException("Method setURL() not yet implemented.");
907 }
908
909 public ParameterMetaData getParameterMetaData() throws SQLException {
910 /***@todo Implement this java.sql.PreparedStatement method*/
911 throw new java.lang.UnsupportedOperationException(
912 "Method getParameterMetaData() not yet implemented.");
913 }
914
915 }
This page was automatically generated by Maven