0001: package org.webdocwf.util.xml;
0002:
0003: import java.sql.PreparedStatement;
0004: import java.sql.ResultSet;
0005: import java.sql.SQLException;
0006: import java.math.BigDecimal;
0007: import java.sql.Date;
0008: import java.sql.Time;
0009: import java.sql.Timestamp;
0010: import java.io.InputStream;
0011: import java.io.Reader;
0012: import java.sql.NClob;
0013: import java.sql.Ref;
0014: import java.sql.Blob;
0015: import java.sql.Clob;
0016: import java.sql.Array;
0017: import java.sql.ResultSetMetaData;
0018: import java.sql.RowId;
0019: import java.sql.SQLException;
0020: import java.sql.SQLXML;
0021: import java.util.Calendar;
0022: import java.net.URL;
0023: import java.sql.ParameterMetaData;
0024: import java.sql.SQLWarning;
0025: import java.sql.Connection;
0026: import java.sql.DriverManager;
0027: import java.io.File;
0028: import java.util.*;
0029:
0030: /**
0031: * Class implements the JDBC PreparedStatement interface for the XmlJdbc driver.
0032: *
0033: * @author Zoran Milakovic
0034: */
0035:
0036: public class XmlPreparedStatement implements PreparedStatement {
0037:
0038: private XmlConnection connection;
0039: private Vector resultSets = new Vector();
0040: private String sqlForPrepare = "";
0041: private String sqlPrepared = "";
0042: private int paramCount = 0;
0043: private ArrayList parameters = new ArrayList();
0044: private ArrayList binaryStreamParameters = new ArrayList();
0045: private String fileName;
0046: public static String PREPARE_SEPARATOR = "~@#NEXTPARAMETER#@~";
0047:
0048: public XmlPreparedStatement(XmlConnection connection,
0049: String preparedSql) {
0050: DriverManager.println("XmlJdbc - XmlStatement() - connection="
0051: + connection);
0052: this .sqlForPrepare = preparedSql;
0053: this .sqlPrepared = preparedSql;
0054: this .paramCount = countParameters(preparedSql);
0055: for (int i = 0; i < paramCount; i++)
0056: parameters.add("null");
0057: this .connection = connection;
0058: this .fileName = connection.getPath()
0059: + connection.getExtension();
0060: }
0061:
0062: private int countParameters(String sql) {
0063: int count = 0;
0064: int index = sql.indexOf(PREPARE_SEPARATOR);
0065: while (index != -1) {
0066: count++;
0067: sql = sql.substring(index + 1);
0068: index = sql.indexOf(PREPARE_SEPARATOR);
0069: }
0070: return count;
0071: }
0072:
0073: private boolean prepareSql() throws SQLException {
0074: boolean retVal = true;
0075:
0076: for (int i = 0; i < parameters.size(); i++) {
0077: int index = sqlPrepared.indexOf(PREPARE_SEPARATOR);
0078: if (index != -1) {
0079: sqlPrepared = sqlPrepared.substring(0, index)
0080: + parameters.get(i)
0081: + sqlPrepared.substring(index
0082: + PREPARE_SEPARATOR.length());
0083: }
0084: }
0085:
0086: if (sqlPrepared.indexOf(PREPARE_SEPARATOR) != -1)
0087: throw new SQLException(
0088: "All ? in prepared query has to be replaced with values.");
0089: else if (parameters.size() < this .paramCount)
0090: throw new SQLException(
0091: "Number of setted parameters is less than number of parameters in statement.");
0092: else if (parameters.size() > this .paramCount)
0093: throw new SQLException(
0094: "Number of setted parameters is greater than number of parameters in statement.");
0095:
0096: return retVal;
0097: }
0098:
0099: /**
0100: * Sets the maxFieldSize attribute of the XmlStatement object
0101: *
0102: * @param p0 The new maxFieldSize value
0103: * @exception SQLException Description of Exception
0104: * @since
0105: */
0106: public void setMaxFieldSize(int p0) throws SQLException {
0107: throw new SQLException("Not Supported !");
0108: }
0109:
0110: /**
0111: *Sets the maxRows attribute of the XmlStatement object
0112: *
0113: * @param p0 The new maxRows value
0114: * @exception SQLException Description of Exception
0115: * @since
0116: */
0117: public void setMaxRows(int p0) throws SQLException {
0118: throw new SQLException("Not Supported !");
0119: }
0120:
0121: /**
0122: *Sets the escapeProcessing attribute of the XmlStatement object
0123: *
0124: * @param p0 The new escapeProcessing value
0125: * @exception SQLException Description of Exception
0126: * @since
0127: */
0128: public void setEscapeProcessing(boolean p0) throws SQLException {
0129: throw new SQLException("Not Supported !");
0130: }
0131:
0132: /**
0133: *Sets the queryTimeout attribute of the XmlStatement object
0134: *
0135: * @param p0 The new queryTimeout value
0136: * @exception SQLException Description of Exception
0137: * @since
0138: */
0139: public void setQueryTimeout(int p0) throws SQLException {
0140: throw new SQLException("Not Supported !");
0141: }
0142:
0143: /**
0144: *Sets the cursorName attribute of the XmlStatement object
0145: *
0146: * @param p0 The new cursorName value
0147: * @exception SQLException Description of Exception
0148: * @since
0149: */
0150: public void setCursorName(String p0) throws SQLException {
0151: throw new SQLException("Not Supported !");
0152: }
0153:
0154: /**
0155: *Sets the fetchDirection attribute of the XmlStatement object
0156: *
0157: * @param p0 The new fetchDirection value
0158: * @exception SQLException Description of Exception
0159: * @since
0160: */
0161: public void setFetchDirection(int p0) throws SQLException {
0162: throw new SQLException("Not Supported !");
0163: }
0164:
0165: /**
0166: *Sets the fetchSize attribute of the XmlStatement object
0167: *
0168: * @param p0 The new fetchSize value
0169: * @exception SQLException Description of Exception
0170: * @since
0171: */
0172: public void setFetchSize(int p0) throws SQLException {
0173: throw new SQLException("Not Supported !");
0174: }
0175:
0176: /**
0177: *Gets the maxFieldSize attribute of the XmlStatement object
0178: *
0179: * @return The maxFieldSize value
0180: * @exception SQLException Description of Exception
0181: * @since
0182: */
0183: public int getMaxFieldSize() throws SQLException {
0184: throw new SQLException("Not Supported !");
0185: }
0186:
0187: /**
0188: *Gets the maxRows attribute of the XmlStatement object
0189: *
0190: * @return The maxRows value
0191: * @exception SQLException Description of Exception
0192: * @since
0193: */
0194: public int getMaxRows() throws SQLException {
0195: throw new SQLException("Not Supported !");
0196: }
0197:
0198: /**
0199: *Gets the queryTimeout attribute of the XmlStatement object
0200: *
0201: * @return The queryTimeout value
0202: * @exception SQLException Description of Exception
0203: * @since
0204: */
0205: public int getQueryTimeout() throws SQLException {
0206: throw new SQLException("Not Supported !");
0207: }
0208:
0209: /**
0210: *Gets the warnings attribute of the XmlStatement object
0211: *
0212: * @return The warnings value
0213: * @exception SQLException Description of Exception
0214: * @since
0215: */
0216: public SQLWarning getWarnings() throws SQLException {
0217: throw new SQLException("Not Supported !");
0218: }
0219:
0220: /**
0221: *Gets the resultSet attribute of the XmlStatement object
0222: *
0223: * @return The resultSet value
0224: * @exception SQLException Description of Exception
0225: * @since
0226: */
0227: public ResultSet getResultSet() throws SQLException {
0228: throw new SQLException("Not Supported !");
0229: }
0230:
0231: /**
0232: *Gets the updateCount attribute of the XmlStatement object
0233: *
0234: * @return The updateCount value
0235: * @exception SQLException Description of Exception
0236: * @since
0237: */
0238: public int getUpdateCount() throws SQLException {
0239: throw new SQLException("Not Supported !");
0240: }
0241:
0242: /**
0243: *Gets the moreResults attribute of the XmlStatement object
0244: *
0245: * @return The moreResults value
0246: * @exception SQLException Description of Exception
0247: * @since
0248: */
0249: public boolean getMoreResults() throws SQLException {
0250: throw new SQLException("Not Supported !");
0251: }
0252:
0253: /**
0254: *Gets the fetchDirection attribute of the XmlStatement object
0255: *
0256: * @return The fetchDirection value
0257: * @exception SQLException Description of Exception
0258: * @since
0259: */
0260: public int getFetchDirection() throws SQLException {
0261: throw new SQLException("Not Supported !");
0262: }
0263:
0264: /**
0265: *Gets the fetchSize attribute of the XmlStatement object
0266: *
0267: * @return The fetchSize value
0268: * @exception SQLException Description of Exception
0269: * @since
0270: */
0271: public int getFetchSize() throws SQLException {
0272: throw new SQLException("Not Supported !");
0273: }
0274:
0275: /**
0276: *Gets the resultSetConcurrency attribute of the XmlStatement object
0277: *
0278: * @return The resultSetConcurrency value
0279: * @exception SQLException Description of Exception
0280: * @since
0281: */
0282: public int getResultSetConcurrency() throws SQLException {
0283: throw new SQLException("Not Supported !");
0284: }
0285:
0286: /**
0287: *Gets the resultSetType attribute of the XmlStatement object
0288: *
0289: * @return The resultSetType value
0290: * @exception SQLException Description of Exception
0291: * @since
0292: */
0293: public int getResultSetType() throws SQLException {
0294: throw new SQLException("Not Supported !");
0295: }
0296:
0297: /**
0298: *Gets the connection attribute of the XmlStatement object
0299: *
0300: * @return The connection value
0301: * @exception SQLException Description of Exception
0302: * @since
0303: */
0304: public Connection getConnection() throws SQLException {
0305: return connection;
0306: }
0307:
0308: public ResultSet executeQuery(String sql) throws SQLException {
0309: DriverManager
0310: .println("XmlJdbc - XmlStatement:executeQuery() - sql= "
0311: + sql);
0312: XmlWriter writer;
0313: if (this .connection.getAutoCommit())
0314: writer = new XmlWriter(fileName, true);
0315: else
0316: writer = new XmlWriter(fileName, false);
0317: XmlSqlParser parser = new XmlSqlParser(this .fileName,
0318: this .connection.getAutoCommit());
0319: if (binaryStreamParameters.size() != 0)
0320: parser.setBinaryStreamList(binaryStreamParameters);
0321: try {
0322: parser.parse(sql);
0323: } catch (Exception e) {
0324: throw new SQLException("Syntax Error. " + e.getMessage());
0325: }
0326: if (parser.sqlType.equals(parser.DROP_TABLE)) {
0327: execute(sql);
0328: return null;
0329: }
0330: if (parser.sqlType.equals(parser.DELETE)) {
0331: executeUpdate(sql);
0332: return null;
0333: }
0334: if (parser.sqlType.equals(parser.UPDATE)) {
0335: executeUpdate(sql);
0336: return null;
0337: } else if (parser.sqlType.equals(parser.INSERT)) {
0338: executeUpdate(sql);
0339: return null;
0340: } else if (parser.sqlType.equals(parser.CREATE_TABLE)) {
0341: execute(sql);
0342: return null;
0343: } else if (parser.sqlType.equals(parser.SELECT)) {
0344:
0345: String fileName = connection.getPath()
0346: + connection.getExtension();
0347: File checkFile = new File(fileName);
0348: XmlReader reader;
0349: try {
0350: reader = new XmlReader(fileName);
0351: String[] xxx = parser.getColumnNames();
0352: String[] yyy = (String[]) writer.getTableProperties(
0353: parser.getTableName()).get(0);
0354: boolean isOK = true;
0355: for (int i = 0; i < xxx.length; i++) {
0356: out: for (int j = 0; j < yyy.length; j++) {
0357: if (xxx[i].equalsIgnoreCase(yyy[j])) {
0358: isOK = true;
0359: break out;
0360: } else
0361: isOK = false;
0362: }
0363: if (!isOK)
0364: throw new SQLException("Column '" + xxx[i]
0365: + "' not found in table "
0366: + parser.getTableName());
0367: }
0368: } catch (Exception e) {
0369: throw new SQLException(
0370: "Error reading data file. Message was: " + e);
0371: }
0372: XmlResultSet resultSet = new XmlResultSet(this , reader,
0373: parser.getTableName(), parser.getColumnNames(),
0374: parser.getWhereColumnNames(), parser
0375: .getWhereColumnValues());
0376: resultSet.select();
0377: return resultSet;
0378: } else {
0379: throw new SQLException(
0380: "Syntax error.Not supported sql statement.");
0381: }
0382: }
0383:
0384: /**
0385: * Insert data into XML database
0386: *
0387: * @param sql Description of Parameter
0388: * @return Description of the Returned Value
0389: * @exception SQLException Description of Exception
0390: * @since
0391: */
0392: public int executeUpdate(String sql) throws SQLException {
0393: DriverManager
0394: .println("XmlJdbc - XmlStatement:executeUpdate() - sql= "
0395: + sql);
0396: XmlSqlParser parser = new XmlSqlParser();
0397: if (binaryStreamParameters.size() != 0)
0398: parser.setBinaryStreamList(binaryStreamParameters);
0399: try {
0400: parser.parse(sql);
0401: } catch (Exception e) {
0402: throw new SQLException("Syntax Error. " + e.getMessage());
0403: }
0404: if (parser.sqlType.equals(parser.SELECT))
0405: throw new SQLException(
0406: "Not supported SELECT statement - use executeQuery() method");
0407: else if (parser.sqlType.equals(parser.CREATE_TABLE)) {
0408: throw new SQLException(
0409: "Not supported CREATE_TABLE statement - use execute() method");
0410: } else if (parser.sqlType.equals(parser.DROP_TABLE)) {
0411: throw new SQLException(
0412: "Not supported DROP_TABLE statement - use execute() method");
0413: } else if (parser.sqlType.equals(parser.INSERT)) {
0414: String fileName = connection.getPath()
0415: + connection.getExtension();
0416: XmlWriter writeXml;
0417: try {
0418: if (this .connection.getAutoCommit())
0419: writeXml = new XmlWriter(fileName, true);
0420: else
0421: writeXml = new XmlWriter(fileName, false);
0422: ArrayList properties = writeXml
0423: .getTableProperties(parser.tableName);
0424: //check for existance of columns
0425: String[] xxx = parser.getColumnNames();
0426: String[] yyy = (String[]) properties.get(0);
0427: boolean isOK = true;
0428: for (int i = 0; i < xxx.length; i++) {
0429: if (!xxx[i].endsWith("*")) {
0430: out: for (int j = 0; j < yyy.length; j++) {
0431: if (xxx[i].equalsIgnoreCase(yyy[j])) {
0432: isOK = true;
0433: break out;
0434: } else
0435: isOK = false;
0436: }
0437: if (!isOK)
0438: throw new SQLException("Column '" + xxx[i]
0439: + "' not found in table "
0440: + parser.getTableName());
0441: }
0442: }
0443: //check if NOTNULL columns is set
0444: if (!properties.get(1).toString().equalsIgnoreCase(
0445: "NO CREATE TABLE")) {
0446: yyy = parser.getColumnNames();
0447: xxx = (String[]) writeXml.getTableProperties(
0448: parser.tableName).get(2);
0449: isOK = true;
0450: for (int i = 0; i < xxx.length; i++) {
0451: out: for (int j = 0; j < yyy.length; j++) {
0452: if (xxx[i].equalsIgnoreCase(yyy[j])) {
0453: isOK = true;
0454: break out;
0455: } else
0456: isOK = false;
0457: }
0458: if (!isOK)
0459: throw new SQLException("Column '" + xxx[i]
0460: + "' can not be NULL.");
0461: }
0462: }
0463: writeXml.insert(parser.getTableName(), parser
0464: .getColumnNames(), parser.getColumnValues());
0465: } catch (Exception e) {
0466: throw new SQLException(
0467: "Error reading data file. Message was: " + e);
0468: }
0469:
0470: } else if (parser.sqlType.equals(parser.UPDATE)) {
0471: String fileName = connection.getPath()
0472: + connection.getExtension();
0473: XmlWriter writeXml;
0474: try {
0475: if (this .connection.getAutoCommit())
0476: writeXml = new XmlWriter(fileName, true);
0477: else
0478: writeXml = new XmlWriter(fileName, false);
0479: String[] xxx = parser.getColumnNames();
0480: String[] yyy = (String[]) writeXml.getTableProperties(
0481: parser.tableName).get(0);
0482: boolean isOK = true;
0483: for (int i = 0; i < xxx.length; i++) {
0484: if (!xxx[i].endsWith("*")) {
0485: out: for (int j = 0; j < yyy.length; j++) {
0486: if (xxx[i].equalsIgnoreCase(yyy[j])) {
0487: isOK = true;
0488: break out;
0489: } else
0490: isOK = false;
0491: }
0492: if (!isOK)
0493: throw new SQLException("Column '" + xxx[i]
0494: + "' not found in table "
0495: + parser.getTableName());
0496: }
0497: }
0498: writeXml.update(parser.getTableName(), parser
0499: .getColumnNames(), parser.getColumnValues(),
0500: parser.getWhereColumnNames(), parser
0501: .getWhereColumnValues());
0502: } catch (Exception e) {
0503: throw new SQLException(
0504: "Error reading data file. Message was: " + e);
0505: }
0506:
0507: } else if (parser.sqlType.equals(parser.DELETE)) {
0508: String fileName = connection.getPath()
0509: + connection.getExtension();
0510: XmlWriter writeXml;
0511: try {
0512: if (this .connection.getAutoCommit())
0513: writeXml = new XmlWriter(fileName, true);
0514: else
0515: writeXml = new XmlWriter(fileName, false);
0516: String[] xxx = parser.getWhereColumnNames();
0517: String[] yyy = (String[]) writeXml.getTableProperties(
0518: parser.tableName).get(0);
0519: boolean isOK = true;
0520: for (int i = 0; i < xxx.length; i++) {
0521: if (!xxx[i].endsWith("*")) {
0522: out: for (int j = 0; j < yyy.length; j++) {
0523: if (xxx[i].equalsIgnoreCase(yyy[j])) {
0524: isOK = true;
0525: break out;
0526: } else
0527: isOK = false;
0528: }
0529: if (!isOK)
0530: throw new SQLException("Column '" + xxx[i]
0531: + "' not found in table "
0532: + parser.getTableName());
0533: }
0534: }
0535: writeXml.delete(parser.getTableName(), parser
0536: .getWhereColumnNames(), parser
0537: .getWhereColumnValues());
0538: } catch (Exception e) {
0539: throw new SQLException(
0540: "Error reading data file. Message was: " + e);
0541: }
0542:
0543: } else if (parser.sqlType.equals(parser.DROP_TABLE)) {
0544: }
0545: return 0;
0546:
0547: }
0548:
0549: /**
0550: * Releases this <code>Statement</code> object's database
0551: * and JDBC resources immediately instead of waiting for
0552: * this to happen when it is automatically closed.
0553: * It is generally good practice to release resources as soon as
0554: * you are finished with them to avoid tying up database
0555: * resources.
0556: * <P>
0557: * Calling the method <code>close</code> on a <code>Statement</code>
0558: * object that is already closed has no effect.
0559: * <P>
0560: * <B>Note:</B> A <code>Statement</code> object is automatically closed
0561: * when it is garbage collected. When a <code>Statement</code> object is
0562: * closed, its current <code>ResultSet</code> object, if one exists, is
0563: * also closed.
0564: *
0565: * @exception SQLException if a database access error occurs
0566: */
0567: public void close() throws SQLException {
0568: // close all result sets
0569: }
0570:
0571: /**
0572: *Description of the Method
0573: *
0574: * @exception SQLException Description of Exception
0575: * @since
0576: */
0577: public void cancel() throws SQLException {
0578: throw new SQLException("Not Supported !");
0579: }
0580:
0581: /**
0582: *Description of the Method
0583: *
0584: * @exception SQLException Description of Exception
0585: * @since
0586: */
0587: public void clearWarnings() throws SQLException {
0588: throw new SQLException("Not Supported !");
0589: }
0590:
0591: /**
0592: *Description of the Method
0593: *
0594: * @param sql Description of Parameter
0595: * @return Description of the Returned Value
0596: * @exception SQLException Description of Exception
0597: * @since
0598: */
0599: public boolean execute(String sql) throws SQLException {
0600: XmlWriter writeXml;
0601: if (this .connection.getAutoCommit())
0602: writeXml = new XmlWriter(fileName, true);
0603: else
0604: writeXml = new XmlWriter(fileName, false);
0605: XmlSqlParser parser = new XmlSqlParser(this .fileName,
0606: this .connection.getAutoCommit());
0607: if (binaryStreamParameters.size() != 0)
0608: parser.setBinaryStreamList(binaryStreamParameters);
0609: try {
0610: parser.parse(sql);
0611: } catch (Exception e) {
0612: throw new SQLException("Syntax Error. " + e.getMessage());
0613: }
0614: if (parser.sqlType.equals(parser.SELECT))
0615: throw new SQLException(
0616: "Use executeQuery() for SELECT statement");
0617: else if (parser.sqlType.equals(parser.UPDATE))
0618: executeUpdate(sql);
0619: else if (parser.sqlType.equals(parser.INSERT))
0620: executeUpdate(sql);
0621: else if (parser.sqlType.equals(parser.DELETE))
0622: executeUpdate(sql);
0623: else if (parser.sqlType.equals(parser.CREATE_TABLE)) {
0624: String fileName = connection.getPath()
0625: + connection.getExtension();
0626: try {
0627: writeXml.createTable(parser.getSqlStatement(), parser
0628: .getTableName());
0629: } catch (Exception e) {
0630: throw new SQLException(
0631: "Error reading data file. Message was: " + e);
0632: }
0633: } else if (parser.sqlType.equals(parser.DROP_TABLE)) {
0634: String fileName = connection.getPath()
0635: + connection.getExtension();
0636: try {
0637: writeXml.dropTable(parser.getTableName());
0638: } catch (Exception e) {
0639: throw new SQLException(
0640: "Error reading data file. Message was: " + e);
0641: }
0642: }
0643: return true;
0644:
0645: }
0646:
0647: /**
0648: * Set String as parameter in sql statement.
0649: * @param parameterIndex
0650: * @param value
0651: * @throws SQLException
0652: */
0653: public void setString(int parameterIndex, String value)
0654: throws SQLException {
0655: if (value == null)
0656: value = "null";
0657: value = Utils.replaceAll(value, "'", XmlSqlParser.quoteEscape);
0658:
0659: XmlDriver.log("XmlPreparedStatement.setString(), value = "
0660: + value);
0661:
0662: parameters.set(parameterIndex - 1, "'" + value + "'");
0663: }
0664:
0665: /**
0666: *
0667: * @param parameterIndex
0668: * @param value
0669: * @throws SQLException
0670: */
0671: public void setBinaryStream(int parameterIndex, InputStream value,
0672: int length) throws SQLException {
0673: throw new SQLException("Not Supported !");
0674: }
0675:
0676: /**
0677: *
0678: * @param parameterIndex
0679: * @param value
0680: * @throws SQLException
0681: */
0682: public void setBytes(int parameterIndex, byte[] value)
0683: throws SQLException {
0684: binaryStreamParameters.add(Utils.bytesToHexString(value));
0685: String paramName = XmlSqlParser.BINARY_STREAM_OBJECT
0686: + binaryStreamParameters.size();
0687: parameters.set(parameterIndex - 1, paramName);
0688: }
0689:
0690: /**
0691: *
0692: * @param parameterIndex
0693: * @param value
0694: * @throws SQLException
0695: */
0696: public void setBlob(int parameterIndex, Blob value)
0697: throws SQLException {
0698: throw new SQLException("Not Supported !");
0699: }
0700:
0701: /**
0702: * Adds a feature to the Batch attribute of the XmlStatement object
0703: *
0704: * @param p0 The feature to be added to the Batch attribute
0705: * @exception SQLException Description of Exception
0706: * @since
0707: */
0708: public void addBatch(String p0) throws SQLException {
0709: throw new SQLException("Not Supported !");
0710: }
0711:
0712: /**
0713: *Description of the Method
0714: *
0715: * @exception SQLException Description of Exception
0716: * @since
0717: */
0718: public void clearBatch() throws SQLException {
0719: throw new SQLException("Not Supported !");
0720: }
0721:
0722: /**
0723: *Description of the Method
0724: *
0725: * @return Description of the Returned Value
0726: * @exception SQLException Description of Exception
0727: * @since
0728: */
0729: public int[] executeBatch() throws SQLException {
0730: throw new SQLException("Not Supported !");
0731: }
0732:
0733: //---------------------------------------------------------------------
0734: // JDBC 3.0
0735: //---------------------------------------------------------------------
0736:
0737: public boolean getMoreResults(int current) throws SQLException {
0738: throw new UnsupportedOperationException(
0739: "Statement.getMoreResults(int) unsupported");
0740: }
0741:
0742: public ResultSet getGeneratedKeys() throws SQLException {
0743: throw new UnsupportedOperationException(
0744: "Statement.getGeneratedKeys() unsupported");
0745: }
0746:
0747: public int executeUpdate(String sql, int autoGeneratedKeys)
0748: throws SQLException {
0749: throw new UnsupportedOperationException(
0750: "Statement.executeUpdate(String,int) unsupported");
0751: }
0752:
0753: public int executeUpdate(String sql, int[] columnIndexes)
0754: throws SQLException {
0755: throw new UnsupportedOperationException(
0756: "Statement.executeUpdate(String,int[]) unsupported");
0757: }
0758:
0759: public int executeUpdate(String sql, String[] columnNames)
0760: throws SQLException {
0761: throw new UnsupportedOperationException(
0762: "Statement.executeUpdate(String,String[]) unsupported");
0763: }
0764:
0765: public boolean execute(String sql, int autoGeneratedKeys)
0766: throws SQLException {
0767: throw new UnsupportedOperationException(
0768: "Statement.execute(String,int) unsupported");
0769: }
0770:
0771: public boolean execute(String sql, int[] columnIndexes)
0772: throws SQLException {
0773: throw new UnsupportedOperationException(
0774: "Statement.execute(String,int[]) unsupported");
0775: }
0776:
0777: public boolean execute(String sql, String[] columnNames)
0778: throws SQLException {
0779: throw new UnsupportedOperationException(
0780: "Statement.execute(String,String[]) unsupported");
0781: }
0782:
0783: public int getResultSetHoldability() throws SQLException {
0784: throw new UnsupportedOperationException(
0785: "Statement.getResultSetHoldability() unsupported");
0786: }
0787:
0788: public ResultSet executeQuery() throws SQLException {
0789: if (!prepareSql())
0790: throw new SQLException("Error with prepared statement !");
0791: return executeQuery(this .sqlPrepared);
0792:
0793: }
0794:
0795: public int executeUpdate() throws SQLException {
0796: if (!prepareSql())
0797: throw new SQLException("Error with prepared statement !");
0798: executeUpdate(this .sqlPrepared);
0799: return 0;
0800: }
0801:
0802: public void setNull(int parameterIndex, int sqlType)
0803: throws SQLException {
0804: this .setString(parameterIndex, "null");
0805: }
0806:
0807: public void setBoolean(int parameterIndex, boolean value)
0808: throws SQLException {
0809: this .setString(parameterIndex, String.valueOf(value));
0810: }
0811:
0812: public void setByte(int parameterIndex, byte value)
0813: throws SQLException {
0814: this .setString(parameterIndex, String.valueOf(value));
0815: }
0816:
0817: public void setShort(int parameterIndex, short value)
0818: throws SQLException {
0819: this .setString(parameterIndex, String.valueOf(value));
0820: }
0821:
0822: public void setInt(int parameterIndex, int value)
0823: throws SQLException {
0824: this .setString(parameterIndex, String.valueOf(value));
0825: }
0826:
0827: public void setLong(int parameterIndex, long value)
0828: throws SQLException {
0829: this .setString(parameterIndex, String.valueOf(value));
0830: }
0831:
0832: public void setFloat(int parameterIndex, float value)
0833: throws SQLException {
0834: this .setString(parameterIndex, String.valueOf(value));
0835: }
0836:
0837: public void setDouble(int parameterIndex, double value)
0838: throws SQLException {
0839: this .setString(parameterIndex, String.valueOf(value));
0840: }
0841:
0842: public void setBigDecimal(int parameterIndex, BigDecimal value)
0843: throws SQLException {
0844: if (value == null) {
0845: this .setString(parameterIndex, value.toString());
0846: } else {
0847: this .setString(parameterIndex, "");
0848: }
0849: }
0850:
0851: public void setDate(int parameterIndex, Date value)
0852: throws SQLException {
0853: if (value == null) {
0854: this .setString(parameterIndex, value.toString());
0855: } else {
0856: this .setString(parameterIndex, "");
0857: }
0858: }
0859:
0860: public void setTime(int parameterIndex, Time value)
0861: throws SQLException {
0862: if (value == null) {
0863: this .setString(parameterIndex, value.toString());
0864: } else {
0865: this .setString(parameterIndex, "");
0866: }
0867: }
0868:
0869: public void setTimestamp(int parameterIndex, Timestamp value)
0870: throws SQLException {
0871: if (value == null) {
0872: this .setString(parameterIndex, value.toString());
0873: } else {
0874: this .setString(parameterIndex, "");
0875: }
0876: }
0877:
0878: public void setAsciiStream(int parameterIndex, InputStream x,
0879: int length) throws SQLException {
0880: /**@todo Implement this java.sql.PreparedStatement method*/
0881: throw new java.lang.UnsupportedOperationException(
0882: "Method setAsciiStream() not yet implemented.");
0883: }
0884:
0885: public void setUnicodeStream(int parameterIndex, InputStream x,
0886: int length) throws SQLException {
0887: /**@todo Implement this java.sql.PreparedStatement method*/
0888: throw new java.lang.UnsupportedOperationException(
0889: "Method setUnicodeStream() not yet implemented.");
0890: }
0891:
0892: public void clearParameters() throws SQLException {
0893: this .sqlPrepared = this .sqlForPrepare;
0894: // this.parameters.clear();
0895: for (int i = 0; i < parameters.size(); i++)
0896: parameters.set(i, null);
0897: this .binaryStreamParameters.clear();
0898: }
0899:
0900: public void setObject(int parameterIndex, Object x,
0901: int targetSqlType, int scale) throws SQLException {
0902: /**@todo Implement this java.sql.PreparedStatement method*/
0903: throw new java.lang.UnsupportedOperationException(
0904: "Method setObject() not yet implemented.");
0905: }
0906:
0907: public void setObject(int parameterIndex, Object x,
0908: int targetSqlType) throws SQLException {
0909: /**@todo Implement this java.sql.PreparedStatement method*/
0910: throw new java.lang.UnsupportedOperationException(
0911: "Method setObject() not yet implemented.");
0912: }
0913:
0914: public void setObject(int parameterIndex, Object x)
0915: throws SQLException {
0916: if (x == null)
0917: x = new String("null");
0918: setString(parameterIndex, x.toString());
0919: }
0920:
0921: public boolean execute() throws SQLException {
0922: /**@todo Implement this java.sql.PreparedStatement method*/
0923: throw new java.lang.UnsupportedOperationException(
0924: "Method execute() not yet implemented.");
0925: }
0926:
0927: public void addBatch() throws SQLException {
0928: /**@todo Implement this java.sql.PreparedStatement method*/
0929: throw new java.lang.UnsupportedOperationException(
0930: "Method addBatch() not yet implemented.");
0931: }
0932:
0933: public void setCharacterStream(int parameterIndex, Reader reader,
0934: int length) throws SQLException {
0935: /**@todo Implement this java.sql.PreparedStatement method*/
0936: throw new java.lang.UnsupportedOperationException(
0937: "Method setCharacterStream() not yet implemented.");
0938: }
0939:
0940: public void setRef(int i, Ref x) throws SQLException {
0941: /**@todo Implement this java.sql.PreparedStatement method*/
0942: throw new java.lang.UnsupportedOperationException(
0943: "Method setRef() not yet implemented.");
0944: }
0945:
0946: public void setClob(int i, Clob x) throws SQLException {
0947: /**@todo Implement this java.sql.PreparedStatement method*/
0948: throw new java.lang.UnsupportedOperationException(
0949: "Method setClob() not yet implemented.");
0950: }
0951:
0952: public void setArray(int i, Array x) throws SQLException {
0953: /**@todo Implement this java.sql.PreparedStatement method*/
0954: throw new java.lang.UnsupportedOperationException(
0955: "Method setArray() not yet implemented.");
0956: }
0957:
0958: public ResultSetMetaData getMetaData() throws SQLException {
0959: /**@todo Implement this java.sql.PreparedStatement method*/
0960: throw new java.lang.UnsupportedOperationException(
0961: "Method getMetaData() not yet implemented.");
0962: }
0963:
0964: public void setDate(int parameterIndex, Date x, Calendar cal)
0965: throws SQLException {
0966: /**@todo Implement this java.sql.PreparedStatement method*/
0967: throw new java.lang.UnsupportedOperationException(
0968: "Method setDate() not yet implemented.");
0969: }
0970:
0971: public void setTime(int parameterIndex, Time x, Calendar cal)
0972: throws SQLException {
0973: /**@todo Implement this java.sql.PreparedStatement method*/
0974: throw new java.lang.UnsupportedOperationException(
0975: "Method setTime() not yet implemented.");
0976: }
0977:
0978: public void setTimestamp(int parameterIndex, Timestamp x,
0979: Calendar cal) throws SQLException {
0980: /**@todo Implement this java.sql.PreparedStatement method*/
0981: throw new java.lang.UnsupportedOperationException(
0982: "Method setTimestamp() not yet implemented.");
0983: }
0984:
0985: public void setNull(int paramIndex, int sqlType, String typeName)
0986: throws SQLException {
0987: this .setString(paramIndex, "null");
0988: }
0989:
0990: public void setURL(int parameterIndex, URL x) throws SQLException {
0991: /**@todo Implement this java.sql.PreparedStatement method*/
0992: throw new java.lang.UnsupportedOperationException(
0993: "Method setURL() not yet implemented.");
0994: }
0995:
0996: public ParameterMetaData getParameterMetaData() throws SQLException {
0997: /**@todo Implement this java.sql.PreparedStatement method*/
0998: throw new java.lang.UnsupportedOperationException(
0999: "Method getParameterMetaData() not yet implemented.");
1000: }
1001:
1002: public void setAsciiStream(int parameterIndex, InputStream x)
1003: throws SQLException {
1004: // TODO Auto-generated method stub
1005: throw new java.lang.UnsupportedOperationException(
1006: "Method setAsciiStream(int,InputStream) not yet implemented.");
1007: }
1008:
1009: public void setAsciiStream(int parameterIndex, InputStream x,
1010: long length) throws SQLException {
1011: // TODO Auto-generated method stub
1012: throw new java.lang.UnsupportedOperationException(
1013: "Method setAsciiStream(int,InputStream,long) not yet implemented.");
1014: }
1015:
1016: public void setBinaryStream(int parameterIndex, InputStream x)
1017: throws SQLException {
1018: // TODO Auto-generated method stub
1019: throw new java.lang.UnsupportedOperationException(
1020: "Method setBinaryStream(int,InputStream) not yet implemented.");
1021: }
1022:
1023: public void setBinaryStream(int parameterIndex, InputStream x,
1024: long length) throws SQLException {
1025: // TODO Auto-generated method stub
1026: throw new java.lang.UnsupportedOperationException(
1027: "Method setBinaryStream(int,InputStream,long) not yet implemented.");
1028: }
1029:
1030: public void setBlob(int parameterIndex, InputStream inputStream)
1031: throws SQLException {
1032: // TODO Auto-generated method stub
1033: throw new java.lang.UnsupportedOperationException(
1034: "Method setBlob(int,InputStream) not yet implemented.");
1035: }
1036:
1037: public void setBlob(int parameterIndex, InputStream inputStream,
1038: long length) throws SQLException {
1039: // TODO Auto-generated method stub
1040: throw new java.lang.UnsupportedOperationException(
1041: "Method setBlob(int,InputStream,long) not yet implemented.");
1042: }
1043:
1044: public void setCharacterStream(int parameterIndex, Reader reader)
1045: throws SQLException {
1046: // TODO Auto-generated method stub
1047: throw new java.lang.UnsupportedOperationException(
1048: "Method setCharacterStream(int,Reader) not yet implemented.");
1049: }
1050:
1051: public void setCharacterStream(int parameterIndex, Reader reader,
1052: long length) throws SQLException {
1053: // TODO Auto-generated method stub
1054: throw new java.lang.UnsupportedOperationException(
1055: "Method setCharacterStream(int,Reader,long) not yet implemented.");
1056: }
1057:
1058: public void setClob(int parameterIndex, Reader reader)
1059: throws SQLException {
1060: // TODO Auto-generated method stub
1061: throw new java.lang.UnsupportedOperationException(
1062: "Method setClob(int,Reader) not yet implemented.");
1063: }
1064:
1065: public void setClob(int parameterIndex, Reader reader, long length)
1066: throws SQLException {
1067: // TODO Auto-generated method stub
1068: throw new java.lang.UnsupportedOperationException(
1069: "Method setClob(int,Reader,long) not yet implemented.");
1070: }
1071:
1072: public void setNCharacterStream(int parameterIndex, Reader value)
1073: throws SQLException {
1074: // TODO Auto-generated method stub
1075: throw new java.lang.UnsupportedOperationException(
1076: "Method setNCharacterStream(int,Reader) not yet implemented.");
1077: }
1078:
1079: public void setNCharacterStream(int parameterIndex, Reader value,
1080: long length) throws SQLException {
1081: // TODO Auto-generated method stub
1082: throw new java.lang.UnsupportedOperationException(
1083: "Method setNCharacterStream(int,Reader,long) not yet implemented.");
1084: }
1085:
1086: public void setNClob(int parameterIndex, NClob value)
1087: throws SQLException {
1088: // TODO Auto-generated method stub
1089: throw new java.lang.UnsupportedOperationException(
1090: "Method setNClob(int,NClob) not yet implemented.");
1091: }
1092:
1093: public void setNClob(int parameterIndex, Reader reader)
1094: throws SQLException {
1095: // TODO Auto-generated method stub
1096: throw new java.lang.UnsupportedOperationException(
1097: "Method setNClob(int,Reader) not yet implemented.");
1098: }
1099:
1100: public void setNClob(int parameterIndex, Reader reader, long length)
1101: throws SQLException {
1102: // TODO Auto-generated method stub
1103: throw new java.lang.UnsupportedOperationException(
1104: "Method setNClob(int,Reader,long) not yet implemented.");
1105: }
1106:
1107: public void setNString(int parameterIndex, String value)
1108: throws SQLException {
1109: // TODO Auto-generated method stub
1110: throw new java.lang.UnsupportedOperationException(
1111: "Method setNString(int,String) not yet implemented.");
1112: }
1113:
1114: public void setRowId(int parameterIndex, RowId x)
1115: throws SQLException {
1116: // TODO Auto-generated method stub
1117: throw new java.lang.UnsupportedOperationException(
1118: "Method setRowId(int,RowId) not yet implemented.");
1119: }
1120:
1121: public void setSQLXML(int parameterIndex, SQLXML xmlObject)
1122: throws SQLException {
1123: // TODO Auto-generated method stub
1124: throw new java.lang.UnsupportedOperationException(
1125: "Method setSQLXML(int,SQLXML) not yet implemented.");
1126: }
1127:
1128: public boolean isClosed() throws SQLException {
1129: // TODO Auto-generated method stub
1130: return false;
1131: }
1132:
1133: public boolean isPoolable() throws SQLException {
1134: // TODO Auto-generated method stub
1135: return false;
1136: }
1137:
1138: public void setPoolable(boolean poolable) throws SQLException {
1139: // TODO Auto-generated method stub
1140: throw new java.lang.UnsupportedOperationException(
1141: "Method setPoolable(boolean) not yet implemented.");
1142: }
1143:
1144: public boolean isWrapperFor(Class<?> iface) throws SQLException {
1145: // TODO Auto-generated method stub
1146: return false;
1147: }
1148:
1149: public <T> T unwrap(Class<T> iface) throws SQLException {
1150: // TODO Auto-generated method stub
1151: return null;
1152: }
1153:
1154: }
|