0001: /*
0002: Copyright (C) 2002-2007 MySQL AB
0003:
0004: This program is free software; you can redistribute it and/or modify
0005: it under the terms of version 2 of the GNU General Public License as
0006: published by the Free Software Foundation.
0007:
0008: There are special exceptions to the terms and conditions of the GPL
0009: as it is applied to this software. View the full text of the
0010: exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
0011: software distribution.
0012:
0013: This program is distributed in the hope that it will be useful,
0014: but WITHOUT ANY WARRANTY; without even the implied warranty of
0015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0016: GNU General Public License for more details.
0017:
0018: You should have received a copy of the GNU General Public License
0019: along with this program; if not, write to the Free Software
0020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021:
0022:
0023:
0024: */
0025: package com.mysql.jdbc.jdbc2.optional;
0026:
0027: import com.mysql.jdbc.SQLError;
0028: import com.mysql.jdbc.exceptions.NotYetImplementedException;
0029:
0030: import java.io.InputStream;
0031: import java.io.Reader;
0032:
0033: import java.math.BigDecimal;
0034:
0035: import java.net.URL;
0036:
0037: import java.sql.Array;
0038: import java.sql.Blob;
0039: import java.sql.Clob;
0040: import java.sql.Date; //import java.sql.NClob;
0041: import java.sql.ParameterMetaData;
0042: import java.sql.PreparedStatement;
0043: import java.sql.Ref;
0044: import java.sql.ResultSet;
0045: import java.sql.ResultSetMetaData; //import java.sql.RowId;
0046: import java.sql.SQLException; //import java.sql.SQLXML;
0047: import java.sql.Time;
0048: import java.sql.Timestamp;
0049:
0050: import java.util.Calendar;
0051:
0052: /**
0053: * Wraps prepared statements so that errors can be reported correctly to
0054: * ConnectionEventListeners.
0055: *
0056: * @author Mark Matthews
0057: *
0058: * @version $Id: PreparedStatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38
0059: * mmatthews Exp $
0060: */
0061: public class PreparedStatementWrapper extends StatementWrapper
0062: implements PreparedStatement {
0063: PreparedStatementWrapper(ConnectionWrapper c,
0064: MysqlPooledConnection conn, PreparedStatement toWrap) {
0065: super (c, conn, toWrap);
0066: }
0067:
0068: /*
0069: * (non-Javadoc)
0070: *
0071: * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)
0072: */
0073: public void setArray(int parameterIndex, Array x)
0074: throws SQLException {
0075: try {
0076: if (this .wrappedStmt != null) {
0077: ((PreparedStatement) this .wrappedStmt).setArray(
0078: parameterIndex, x);
0079: } else {
0080: throw SQLError.createSQLException(
0081: "No operations allowed after statement closed",
0082: SQLError.SQL_STATE_GENERAL_ERROR);
0083: }
0084: } catch (SQLException sqlEx) {
0085: checkAndFireConnectionError(sqlEx);
0086: }
0087: }
0088:
0089: /*
0090: * (non-Javadoc)
0091: *
0092: * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream,
0093: * int)
0094: */
0095: public void setAsciiStream(int parameterIndex, InputStream x,
0096: int length) throws SQLException {
0097: try {
0098: if (this .wrappedStmt != null) {
0099: ((PreparedStatement) this .wrappedStmt).setAsciiStream(
0100: parameterIndex, x, length);
0101: } else {
0102: throw SQLError.createSQLException(
0103: "No operations allowed after statement closed",
0104: SQLError.SQL_STATE_GENERAL_ERROR);
0105: }
0106: } catch (SQLException sqlEx) {
0107: checkAndFireConnectionError(sqlEx);
0108: }
0109: }
0110:
0111: /*
0112: * (non-Javadoc)
0113: *
0114: * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)
0115: */
0116: public void setBigDecimal(int parameterIndex, BigDecimal x)
0117: throws SQLException {
0118: try {
0119: if (this .wrappedStmt != null) {
0120: ((PreparedStatement) this .wrappedStmt).setBigDecimal(
0121: parameterIndex, x);
0122: } else {
0123: throw SQLError.createSQLException(
0124: "No operations allowed after statement closed",
0125: SQLError.SQL_STATE_GENERAL_ERROR);
0126: }
0127: } catch (SQLException sqlEx) {
0128: checkAndFireConnectionError(sqlEx);
0129: }
0130: }
0131:
0132: /*
0133: * (non-Javadoc)
0134: *
0135: * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream,
0136: * int)
0137: */
0138: public void setBinaryStream(int parameterIndex, InputStream x,
0139: int length) throws SQLException {
0140: try {
0141: if (this .wrappedStmt != null) {
0142: ((PreparedStatement) this .wrappedStmt).setBinaryStream(
0143: parameterIndex, x, length);
0144: } else {
0145: throw SQLError.createSQLException(
0146: "No operations allowed after statement closed",
0147: SQLError.SQL_STATE_GENERAL_ERROR);
0148: }
0149: } catch (SQLException sqlEx) {
0150: checkAndFireConnectionError(sqlEx);
0151: }
0152: }
0153:
0154: /*
0155: * (non-Javadoc)
0156: *
0157: * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)
0158: */
0159: public void setBlob(int parameterIndex, Blob x) throws SQLException {
0160: try {
0161: if (this .wrappedStmt != null) {
0162: ((PreparedStatement) this .wrappedStmt).setBlob(
0163: parameterIndex, x);
0164: } else {
0165: throw SQLError.createSQLException(
0166: "No operations allowed after statement closed",
0167: SQLError.SQL_STATE_GENERAL_ERROR);
0168: }
0169: } catch (SQLException sqlEx) {
0170: checkAndFireConnectionError(sqlEx);
0171: }
0172: }
0173:
0174: /*
0175: * (non-Javadoc)
0176: *
0177: * @see java.sql.PreparedStatement#setBoolean(int, boolean)
0178: */
0179: public void setBoolean(int parameterIndex, boolean x)
0180: throws SQLException {
0181: try {
0182: if (this .wrappedStmt != null) {
0183: ((PreparedStatement) this .wrappedStmt).setBoolean(
0184: parameterIndex, x);
0185: } else {
0186: throw SQLError.createSQLException(
0187: "No operations allowed after statement closed",
0188: SQLError.SQL_STATE_GENERAL_ERROR);
0189: }
0190: } catch (SQLException sqlEx) {
0191: checkAndFireConnectionError(sqlEx);
0192: }
0193: }
0194:
0195: /*
0196: * (non-Javadoc)
0197: *
0198: * @see java.sql.PreparedStatement#setByte(int, byte)
0199: */
0200: public void setByte(int parameterIndex, byte x) throws SQLException {
0201: try {
0202: if (this .wrappedStmt != null) {
0203: ((PreparedStatement) this .wrappedStmt).setByte(
0204: parameterIndex, x);
0205: } else {
0206: throw SQLError.createSQLException(
0207: "No operations allowed after statement closed",
0208: SQLError.SQL_STATE_GENERAL_ERROR);
0209: }
0210: } catch (SQLException sqlEx) {
0211: checkAndFireConnectionError(sqlEx);
0212: }
0213: }
0214:
0215: /*
0216: * (non-Javadoc)
0217: *
0218: * @see java.sql.PreparedStatement#setBytes(int, byte[])
0219: */
0220: public void setBytes(int parameterIndex, byte[] x)
0221: throws SQLException {
0222: try {
0223: if (this .wrappedStmt != null) {
0224: ((PreparedStatement) this .wrappedStmt).setBytes(
0225: parameterIndex, x);
0226: } else {
0227: throw SQLError.createSQLException(
0228: "No operations allowed after statement closed",
0229: SQLError.SQL_STATE_GENERAL_ERROR);
0230: }
0231: } catch (SQLException sqlEx) {
0232: checkAndFireConnectionError(sqlEx);
0233: }
0234: }
0235:
0236: /*
0237: * (non-Javadoc)
0238: *
0239: * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader,
0240: * int)
0241: */
0242: public void setCharacterStream(int parameterIndex, Reader reader,
0243: int length) throws SQLException {
0244: try {
0245: if (this .wrappedStmt != null) {
0246: ((PreparedStatement) this .wrappedStmt)
0247: .setCharacterStream(parameterIndex, reader,
0248: length);
0249: } else {
0250: throw SQLError.createSQLException(
0251: "No operations allowed after statement closed",
0252: SQLError.SQL_STATE_GENERAL_ERROR);
0253: }
0254: } catch (SQLException sqlEx) {
0255: checkAndFireConnectionError(sqlEx);
0256: }
0257: }
0258:
0259: /*
0260: * (non-Javadoc)
0261: *
0262: * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
0263: */
0264: public void setClob(int parameterIndex, Clob x) throws SQLException {
0265: try {
0266: if (this .wrappedStmt != null) {
0267: ((PreparedStatement) this .wrappedStmt).setClob(
0268: parameterIndex, x);
0269: } else {
0270: throw SQLError.createSQLException(
0271: "No operations allowed after statement closed",
0272: SQLError.SQL_STATE_GENERAL_ERROR);
0273: }
0274: } catch (SQLException sqlEx) {
0275: checkAndFireConnectionError(sqlEx);
0276: }
0277: }
0278:
0279: /*
0280: * (non-Javadoc)
0281: *
0282: * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)
0283: */
0284: public void setDate(int parameterIndex, Date x) throws SQLException {
0285: try {
0286: if (this .wrappedStmt != null) {
0287: ((PreparedStatement) this .wrappedStmt).setDate(
0288: parameterIndex, x);
0289: } else {
0290: throw SQLError.createSQLException(
0291: "No operations allowed after statement closed",
0292: SQLError.SQL_STATE_GENERAL_ERROR);
0293: }
0294: } catch (SQLException sqlEx) {
0295: checkAndFireConnectionError(sqlEx);
0296: }
0297: }
0298:
0299: /*
0300: * (non-Javadoc)
0301: *
0302: * @see java.sql.PreparedStatement#setDate(int, java.sql.Date,
0303: * java.util.Calendar)
0304: */
0305: public void setDate(int parameterIndex, Date x, Calendar cal)
0306: throws SQLException {
0307: try {
0308: if (this .wrappedStmt != null) {
0309: ((PreparedStatement) this .wrappedStmt).setDate(
0310: parameterIndex, x, cal);
0311: } else {
0312: throw SQLError.createSQLException(
0313: "No operations allowed after statement closed",
0314: SQLError.SQL_STATE_GENERAL_ERROR);
0315: }
0316: } catch (SQLException sqlEx) {
0317: checkAndFireConnectionError(sqlEx);
0318: }
0319: }
0320:
0321: /*
0322: * (non-Javadoc)
0323: *
0324: * @see java.sql.PreparedStatement#setDouble(int, double)
0325: */
0326: public void setDouble(int parameterIndex, double x)
0327: throws SQLException {
0328: try {
0329: if (this .wrappedStmt != null) {
0330: ((PreparedStatement) this .wrappedStmt).setDouble(
0331: parameterIndex, x);
0332: } else {
0333: throw SQLError.createSQLException(
0334: "No operations allowed after statement closed",
0335: SQLError.SQL_STATE_GENERAL_ERROR);
0336: }
0337: } catch (SQLException sqlEx) {
0338: checkAndFireConnectionError(sqlEx);
0339: }
0340: }
0341:
0342: /*
0343: * (non-Javadoc)
0344: *
0345: * @see java.sql.PreparedStatement#setFloat(int, float)
0346: */
0347: public void setFloat(int parameterIndex, float x)
0348: throws SQLException {
0349: try {
0350: if (this .wrappedStmt != null) {
0351: ((PreparedStatement) this .wrappedStmt).setFloat(
0352: parameterIndex, x);
0353: } else {
0354: throw SQLError.createSQLException(
0355: "No operations allowed after statement closed",
0356: SQLError.SQL_STATE_GENERAL_ERROR);
0357: }
0358: } catch (SQLException sqlEx) {
0359: checkAndFireConnectionError(sqlEx);
0360: }
0361: }
0362:
0363: /*
0364: * (non-Javadoc)
0365: *
0366: * @see java.sql.PreparedStatement#setInt(int, int)
0367: */
0368: public void setInt(int parameterIndex, int x) throws SQLException {
0369: try {
0370: if (this .wrappedStmt != null) {
0371: ((PreparedStatement) this .wrappedStmt).setInt(
0372: parameterIndex, x);
0373: } else {
0374: throw SQLError.createSQLException(
0375: "No operations allowed after statement closed",
0376: SQLError.SQL_STATE_GENERAL_ERROR);
0377: }
0378: } catch (SQLException sqlEx) {
0379: checkAndFireConnectionError(sqlEx);
0380: }
0381: }
0382:
0383: /*
0384: * (non-Javadoc)
0385: *
0386: * @see java.sql.PreparedStatement#setLong(int, long)
0387: */
0388: public void setLong(int parameterIndex, long x) throws SQLException {
0389: try {
0390: if (this .wrappedStmt != null) {
0391: ((PreparedStatement) this .wrappedStmt).setLong(
0392: parameterIndex, x);
0393: } else {
0394: throw SQLError.createSQLException(
0395: "No operations allowed after statement closed",
0396: SQLError.SQL_STATE_GENERAL_ERROR);
0397: }
0398: } catch (SQLException sqlEx) {
0399: checkAndFireConnectionError(sqlEx);
0400: }
0401: }
0402:
0403: /*
0404: * (non-Javadoc)
0405: *
0406: * @see java.sql.PreparedStatement#getMetaData()
0407: */
0408: public ResultSetMetaData getMetaData() throws SQLException {
0409: try {
0410: if (this .wrappedStmt != null) {
0411: return ((PreparedStatement) this .wrappedStmt)
0412: .getMetaData();
0413: }
0414:
0415: throw SQLError.createSQLException(
0416: "No operations allowed after statement closed",
0417: SQLError.SQL_STATE_GENERAL_ERROR);
0418: } catch (SQLException sqlEx) {
0419: checkAndFireConnectionError(sqlEx);
0420: }
0421:
0422: return null;
0423: }
0424:
0425: /*
0426: * (non-Javadoc)
0427: *
0428: * @see java.sql.PreparedStatement#setNull(int, int)
0429: */
0430: public void setNull(int parameterIndex, int sqlType)
0431: throws SQLException {
0432: try {
0433: if (this .wrappedStmt != null) {
0434: ((PreparedStatement) this .wrappedStmt).setNull(
0435: parameterIndex, sqlType);
0436: } else {
0437: throw SQLError.createSQLException(
0438: "No operations allowed after statement closed",
0439: SQLError.SQL_STATE_GENERAL_ERROR);
0440: }
0441: } catch (SQLException sqlEx) {
0442: checkAndFireConnectionError(sqlEx);
0443: }
0444: }
0445:
0446: /*
0447: * (non-Javadoc)
0448: *
0449: * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)
0450: */
0451: public void setNull(int parameterIndex, int sqlType, String typeName)
0452: throws SQLException {
0453: try {
0454: if (this .wrappedStmt != null) {
0455: ((PreparedStatement) this .wrappedStmt).setNull(
0456: parameterIndex, sqlType, typeName);
0457: } else {
0458: throw SQLError.createSQLException(
0459: "No operations allowed after statement closed",
0460: SQLError.SQL_STATE_GENERAL_ERROR);
0461: }
0462: } catch (SQLException sqlEx) {
0463: checkAndFireConnectionError(sqlEx);
0464: }
0465: }
0466:
0467: /*
0468: * (non-Javadoc)
0469: *
0470: * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)
0471: */
0472: public void setObject(int parameterIndex, Object x)
0473: throws SQLException {
0474: try {
0475: if (this .wrappedStmt != null) {
0476: ((PreparedStatement) this .wrappedStmt).setObject(
0477: parameterIndex, x);
0478: } else {
0479: throw SQLError.createSQLException(
0480: "No operations allowed after statement closed",
0481: SQLError.SQL_STATE_GENERAL_ERROR);
0482: }
0483: } catch (SQLException sqlEx) {
0484: checkAndFireConnectionError(sqlEx);
0485: }
0486: }
0487:
0488: /*
0489: * (non-Javadoc)
0490: *
0491: * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)
0492: */
0493: public void setObject(int parameterIndex, Object x,
0494: int targetSqlType) throws SQLException {
0495: try {
0496: if (this .wrappedStmt != null) {
0497: ((PreparedStatement) this .wrappedStmt).setObject(
0498: parameterIndex, x, targetSqlType);
0499: } else {
0500: throw SQLError.createSQLException(
0501: "No operations allowed after statement closed",
0502: SQLError.SQL_STATE_GENERAL_ERROR);
0503: }
0504: } catch (SQLException sqlEx) {
0505: checkAndFireConnectionError(sqlEx);
0506: }
0507: }
0508:
0509: /*
0510: * (non-Javadoc)
0511: *
0512: * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int,
0513: * int)
0514: */
0515: public void setObject(int parameterIndex, Object x,
0516: int targetSqlType, int scale) throws SQLException {
0517: try {
0518: if (this .wrappedStmt != null) {
0519: ((PreparedStatement) this .wrappedStmt).setObject(
0520: parameterIndex, x, targetSqlType, scale);
0521: } else {
0522: throw SQLError.createSQLException(
0523: "No operations allowed after statement closed",
0524: SQLError.SQL_STATE_GENERAL_ERROR);
0525: }
0526: } catch (SQLException sqlEx) {
0527: checkAndFireConnectionError(sqlEx);
0528: }
0529: }
0530:
0531: /*
0532: * (non-Javadoc)
0533: *
0534: * @see java.sql.PreparedStatement#getParameterMetaData()
0535: */
0536: public ParameterMetaData getParameterMetaData() throws SQLException {
0537: try {
0538: if (this .wrappedStmt != null) {
0539: return ((PreparedStatement) this .wrappedStmt)
0540: .getParameterMetaData();
0541: }
0542:
0543: throw SQLError.createSQLException(
0544: "No operations allowed after statement closed",
0545: SQLError.SQL_STATE_GENERAL_ERROR);
0546: } catch (SQLException sqlEx) {
0547: checkAndFireConnectionError(sqlEx);
0548: }
0549:
0550: return null;
0551: }
0552:
0553: /*
0554: * (non-Javadoc)
0555: *
0556: * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)
0557: */
0558: public void setRef(int parameterIndex, Ref x) throws SQLException {
0559: try {
0560: if (this .wrappedStmt != null) {
0561: ((PreparedStatement) this .wrappedStmt).setRef(
0562: parameterIndex, x);
0563: } else {
0564: throw SQLError.createSQLException(
0565: "No operations allowed after statement closed",
0566: SQLError.SQL_STATE_GENERAL_ERROR);
0567: }
0568: } catch (SQLException sqlEx) {
0569: checkAndFireConnectionError(sqlEx);
0570: }
0571: }
0572:
0573: /*
0574: * (non-Javadoc)
0575: *
0576: * @see java.sql.PreparedStatement#setShort(int, short)
0577: */
0578: public void setShort(int parameterIndex, short x)
0579: throws SQLException {
0580: try {
0581: if (this .wrappedStmt != null) {
0582: ((PreparedStatement) this .wrappedStmt).setShort(
0583: parameterIndex, x);
0584: } else {
0585: throw SQLError.createSQLException(
0586: "No operations allowed after statement closed",
0587: SQLError.SQL_STATE_GENERAL_ERROR);
0588: }
0589: } catch (SQLException sqlEx) {
0590: checkAndFireConnectionError(sqlEx);
0591: }
0592: }
0593:
0594: /*
0595: * (non-Javadoc)
0596: *
0597: * @see java.sql.PreparedStatement#setString(int, java.lang.String)
0598: */
0599: public void setString(int parameterIndex, String x)
0600: throws SQLException {
0601: try {
0602: if (this .wrappedStmt != null) {
0603: ((PreparedStatement) this .wrappedStmt).setString(
0604: parameterIndex, x);
0605: } else {
0606: throw SQLError.createSQLException(
0607: "No operations allowed after statement closed",
0608: SQLError.SQL_STATE_GENERAL_ERROR);
0609: }
0610: } catch (SQLException sqlEx) {
0611: checkAndFireConnectionError(sqlEx);
0612: }
0613: }
0614:
0615: /*
0616: * (non-Javadoc)
0617: *
0618: * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)
0619: */
0620: public void setTime(int parameterIndex, Time x) throws SQLException {
0621: try {
0622: if (this .wrappedStmt != null) {
0623: ((PreparedStatement) this .wrappedStmt).setTime(
0624: parameterIndex, x);
0625: } else {
0626: throw SQLError.createSQLException(
0627: "No operations allowed after statement closed",
0628: SQLError.SQL_STATE_GENERAL_ERROR);
0629: }
0630: } catch (SQLException sqlEx) {
0631: checkAndFireConnectionError(sqlEx);
0632: }
0633: }
0634:
0635: /*
0636: * (non-Javadoc)
0637: *
0638: * @see java.sql.PreparedStatement#setTime(int, java.sql.Time,
0639: * java.util.Calendar)
0640: */
0641: public void setTime(int parameterIndex, Time x, Calendar cal)
0642: throws SQLException {
0643: try {
0644: if (this .wrappedStmt != null) {
0645: ((PreparedStatement) this .wrappedStmt).setTime(
0646: parameterIndex, x, cal);
0647: } else {
0648: throw SQLError.createSQLException(
0649: "No operations allowed after statement closed",
0650: SQLError.SQL_STATE_GENERAL_ERROR);
0651: }
0652: } catch (SQLException sqlEx) {
0653: checkAndFireConnectionError(sqlEx);
0654: }
0655: }
0656:
0657: /*
0658: * (non-Javadoc)
0659: *
0660: * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)
0661: */
0662: public void setTimestamp(int parameterIndex, Timestamp x)
0663: throws SQLException {
0664: try {
0665: if (this .wrappedStmt != null) {
0666: ((PreparedStatement) this .wrappedStmt).setTimestamp(
0667: parameterIndex, x);
0668: } else {
0669: throw SQLError.createSQLException(
0670: "No operations allowed after statement closed",
0671: SQLError.SQL_STATE_GENERAL_ERROR);
0672: }
0673: } catch (SQLException sqlEx) {
0674: checkAndFireConnectionError(sqlEx);
0675: }
0676: }
0677:
0678: /*
0679: * (non-Javadoc)
0680: *
0681: * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp,
0682: * java.util.Calendar)
0683: */
0684: public void setTimestamp(int parameterIndex, Timestamp x,
0685: Calendar cal) throws SQLException {
0686: try {
0687: if (this .wrappedStmt != null) {
0688: ((PreparedStatement) this .wrappedStmt).setTimestamp(
0689: parameterIndex, x, cal);
0690: } else {
0691: throw SQLError.createSQLException(
0692: "No operations allowed after statement closed",
0693: SQLError.SQL_STATE_GENERAL_ERROR);
0694: }
0695: } catch (SQLException sqlEx) {
0696: checkAndFireConnectionError(sqlEx);
0697: }
0698: }
0699:
0700: /*
0701: * (non-Javadoc)
0702: *
0703: * @see java.sql.PreparedStatement#setURL(int, java.net.URL)
0704: */
0705: public void setURL(int parameterIndex, URL x) throws SQLException {
0706: try {
0707: if (this .wrappedStmt != null) {
0708: ((PreparedStatement) this .wrappedStmt).setURL(
0709: parameterIndex, x);
0710: } else {
0711: throw SQLError.createSQLException(
0712: "No operations allowed after statement closed",
0713: SQLError.SQL_STATE_GENERAL_ERROR);
0714: }
0715: } catch (SQLException sqlEx) {
0716: checkAndFireConnectionError(sqlEx);
0717: }
0718: }
0719:
0720: /**
0721: * DOCUMENT ME!
0722: *
0723: * @param parameterIndex
0724: * DOCUMENT ME!
0725: * @param x
0726: * DOCUMENT ME!
0727: * @param length
0728: * DOCUMENT ME!
0729: *
0730: * @throws SQLException
0731: * DOCUMENT ME!
0732: *
0733: * @see java.sql.PreparedStatement#setUnicodeStream(int,
0734: * java.io.InputStream, int)
0735: * @deprecated
0736: */
0737: public void setUnicodeStream(int parameterIndex, InputStream x,
0738: int length) throws SQLException {
0739: try {
0740: if (this .wrappedStmt != null) {
0741: ((PreparedStatement) this .wrappedStmt)
0742: .setUnicodeStream(parameterIndex, x, length);
0743: } else {
0744: throw SQLError.createSQLException(
0745: "No operations allowed after statement closed",
0746: SQLError.SQL_STATE_GENERAL_ERROR);
0747: }
0748: } catch (SQLException sqlEx) {
0749: checkAndFireConnectionError(sqlEx);
0750: }
0751: }
0752:
0753: /*
0754: * (non-Javadoc)
0755: *
0756: * @see java.sql.PreparedStatement#addBatch()
0757: */
0758: public void addBatch() throws SQLException {
0759: try {
0760: if (this .wrappedStmt != null) {
0761: ((PreparedStatement) this .wrappedStmt).addBatch();
0762: } else {
0763: throw SQLError.createSQLException(
0764: "No operations allowed after statement closed",
0765: SQLError.SQL_STATE_GENERAL_ERROR);
0766: }
0767: } catch (SQLException sqlEx) {
0768: checkAndFireConnectionError(sqlEx);
0769: }
0770: }
0771:
0772: /*
0773: * (non-Javadoc)
0774: *
0775: * @see java.sql.PreparedStatement#clearParameters()
0776: */
0777: public void clearParameters() throws SQLException {
0778: try {
0779: if (this .wrappedStmt != null) {
0780: ((PreparedStatement) this .wrappedStmt)
0781: .clearParameters();
0782: } else {
0783: throw SQLError.createSQLException(
0784: "No operations allowed after statement closed",
0785: SQLError.SQL_STATE_GENERAL_ERROR);
0786: }
0787: } catch (SQLException sqlEx) {
0788: checkAndFireConnectionError(sqlEx);
0789: }
0790: }
0791:
0792: /*
0793: * (non-Javadoc)
0794: *
0795: * @see java.sql.PreparedStatement#execute()
0796: */
0797: public boolean execute() throws SQLException {
0798: try {
0799: if (this .wrappedStmt != null) {
0800: return ((PreparedStatement) this .wrappedStmt).execute();
0801: }
0802:
0803: throw SQLError.createSQLException(
0804: "No operations allowed after statement closed",
0805: SQLError.SQL_STATE_GENERAL_ERROR);
0806: } catch (SQLException sqlEx) {
0807: checkAndFireConnectionError(sqlEx);
0808: }
0809:
0810: return false; // we actually never get here, but the compiler can't
0811: // figure
0812:
0813: // that out
0814: }
0815:
0816: /*
0817: * (non-Javadoc)
0818: *
0819: * @see java.sql.PreparedStatement#executeQuery()
0820: */
0821: public ResultSet executeQuery() throws SQLException {
0822: try {
0823: if (this .wrappedStmt != null) {
0824: ResultSet rs = ((PreparedStatement) this .wrappedStmt)
0825: .executeQuery();
0826:
0827: ((com.mysql.jdbc.ResultSetInternalMethods) rs)
0828: .setWrapperStatement(this );
0829:
0830: return rs;
0831: }
0832:
0833: throw SQLError.createSQLException(
0834: "No operations allowed after statement closed",
0835: SQLError.SQL_STATE_GENERAL_ERROR);
0836: } catch (SQLException sqlEx) {
0837: checkAndFireConnectionError(sqlEx);
0838: }
0839:
0840: return null; // we actually never get here, but the compiler can't
0841: // figure
0842:
0843: // that out
0844: }
0845:
0846: /*
0847: * (non-Javadoc)
0848: *
0849: * @see java.sql.PreparedStatement#executeUpdate()
0850: */
0851: public int executeUpdate() throws SQLException {
0852: try {
0853: if (this .wrappedStmt != null) {
0854: return ((PreparedStatement) this .wrappedStmt)
0855: .executeUpdate();
0856: }
0857:
0858: throw SQLError.createSQLException(
0859: "No operations allowed after statement closed",
0860: SQLError.SQL_STATE_GENERAL_ERROR);
0861: } catch (SQLException sqlEx) {
0862: checkAndFireConnectionError(sqlEx);
0863: }
0864:
0865: return -1; // we actually never get here, but the compiler can't figure
0866:
0867: // that out
0868: }
0869: //
0870: // public void setAsciiStream(int parameterIndex, InputStream x)
0871: // throws SQLException {
0872: // try {
0873: // if (this.wrappedStmt != null) {
0874: // ((PreparedStatement) this.wrappedStmt).setAsciiStream(
0875: // parameterIndex, x);
0876: // } else {
0877: // throw SQLError.createSQLException(
0878: // "No operations allowed after statement closed",
0879: // SQLError.SQL_STATE_GENERAL_ERROR);
0880: // }
0881: // } catch (SQLException sqlEx) {
0882: // checkAndFireConnectionError(sqlEx);
0883: // }
0884: // }
0885: //
0886: // public void setAsciiStream(int parameterIndex, InputStream x, long length)
0887: // throws SQLException {
0888: // try {
0889: // if (this.wrappedStmt != null) {
0890: // ((PreparedStatement) this.wrappedStmt).setAsciiStream(
0891: // parameterIndex, x, length);
0892: // } else {
0893: // throw SQLError.createSQLException(
0894: // "No operations allowed after statement closed",
0895: // SQLError.SQL_STATE_GENERAL_ERROR);
0896: // }
0897: // } catch (SQLException sqlEx) {
0898: // checkAndFireConnectionError(sqlEx);
0899: // }
0900: // }
0901: //
0902: // public void setBinaryStream(int parameterIndex, InputStream x)
0903: // throws SQLException {
0904: // try {
0905: // if (this.wrappedStmt != null) {
0906: // ((PreparedStatement) this.wrappedStmt).setBinaryStream(
0907: // parameterIndex, x);
0908: // } else {
0909: // throw SQLError.createSQLException(
0910: // "No operations allowed after statement closed",
0911: // SQLError.SQL_STATE_GENERAL_ERROR);
0912: // }
0913: // } catch (SQLException sqlEx) {
0914: // checkAndFireConnectionError(sqlEx);
0915: // }
0916: // }
0917: //
0918: // public void setBinaryStream(int parameterIndex, InputStream x, long length)
0919: // throws SQLException {
0920: // try {
0921: // if (this.wrappedStmt != null) {
0922: // ((PreparedStatement) this.wrappedStmt).setBinaryStream(
0923: // parameterIndex, x, length);
0924: // } else {
0925: // throw SQLError.createSQLException(
0926: // "No operations allowed after statement closed",
0927: // SQLError.SQL_STATE_GENERAL_ERROR);
0928: // }
0929: // } catch (SQLException sqlEx) {
0930: // checkAndFireConnectionError(sqlEx);
0931: // }
0932: // }
0933: //
0934: // public void setBlob(int parameterIndex, InputStream inputStream)
0935: // throws SQLException {
0936: // try {
0937: // if (this.wrappedStmt != null) {
0938: // ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
0939: // inputStream);
0940: // } else {
0941: // throw SQLError.createSQLException(
0942: // "No operations allowed after statement closed",
0943: // SQLError.SQL_STATE_GENERAL_ERROR);
0944: // }
0945: // } catch (SQLException sqlEx) {
0946: // checkAndFireConnectionError(sqlEx);
0947: // }
0948: // }
0949: //
0950: // public void setBlob(int parameterIndex, InputStream inputStream, long length)
0951: // throws SQLException {
0952: // try {
0953: // if (this.wrappedStmt != null) {
0954: // ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
0955: // inputStream, length);
0956: // } else {
0957: // throw SQLError.createSQLException(
0958: // "No operations allowed after statement closed",
0959: // SQLError.SQL_STATE_GENERAL_ERROR);
0960: // }
0961: // } catch (SQLException sqlEx) {
0962: // checkAndFireConnectionError(sqlEx);
0963: // }
0964: // }
0965: //
0966: // public void setCharacterStream(int parameterIndex, Reader reader)
0967: // throws SQLException {
0968: // try {
0969: // if (this.wrappedStmt != null) {
0970: // ((PreparedStatement) this.wrappedStmt).setCharacterStream(
0971: // parameterIndex, reader);
0972: // } else {
0973: // throw SQLError.createSQLException(
0974: // "No operations allowed after statement closed",
0975: // SQLError.SQL_STATE_GENERAL_ERROR);
0976: // }
0977: // } catch (SQLException sqlEx) {
0978: // checkAndFireConnectionError(sqlEx);
0979: // }
0980: // }
0981: //
0982: // public void setCharacterStream(int parameterIndex, Reader reader,
0983: // long length) throws SQLException {
0984: // try {
0985: // if (this.wrappedStmt != null) {
0986: // ((PreparedStatement) this.wrappedStmt).setCharacterStream(
0987: // parameterIndex, reader, length);
0988: // } else {
0989: // throw SQLError.createSQLException(
0990: // "No operations allowed after statement closed",
0991: // SQLError.SQL_STATE_GENERAL_ERROR);
0992: // }
0993: // } catch (SQLException sqlEx) {
0994: // checkAndFireConnectionError(sqlEx);
0995: // }
0996: // }
0997: //
0998: // public void setClob(int parameterIndex, Reader reader) throws SQLException {
0999: // try {
1000: // if (this.wrappedStmt != null) {
1001: // ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
1002: // reader);
1003: // } else {
1004: // throw SQLError.createSQLException(
1005: // "No operations allowed after statement closed",
1006: // SQLError.SQL_STATE_GENERAL_ERROR);
1007: // }
1008: // } catch (SQLException sqlEx) {
1009: // checkAndFireConnectionError(sqlEx);
1010: // }
1011: // }
1012: //
1013: // public void setClob(int parameterIndex, Reader reader, long length)
1014: // throws SQLException {
1015: // try {
1016: // if (this.wrappedStmt != null) {
1017: // ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
1018: // reader, length);
1019: // } else {
1020: // throw SQLError.createSQLException(
1021: // "No operations allowed after statement closed",
1022: // SQLError.SQL_STATE_GENERAL_ERROR);
1023: // }
1024: // } catch (SQLException sqlEx) {
1025: // checkAndFireConnectionError(sqlEx);
1026: // }
1027: // }
1028: //
1029: // public void setNCharacterStream(int parameterIndex, Reader value)
1030: // throws SQLException {
1031: // try {
1032: // if (this.wrappedStmt != null) {
1033: // ((PreparedStatement) this.wrappedStmt).setNCharacterStream(
1034: // parameterIndex, value);
1035: // } else {
1036: // throw SQLError.createSQLException(
1037: // "No operations allowed after statement closed",
1038: // SQLError.SQL_STATE_GENERAL_ERROR);
1039: // }
1040: // } catch (SQLException sqlEx) {
1041: // checkAndFireConnectionError(sqlEx);
1042: // }
1043: // }
1044: //
1045: // public void setNCharacterStream(int parameterIndex, Reader value,
1046: // long length) throws SQLException {
1047: // try {
1048: // if (this.wrappedStmt != null) {
1049: // ((PreparedStatement) this.wrappedStmt).setNCharacterStream(
1050: // parameterIndex, value, length);
1051: // } else {
1052: // throw SQLError.createSQLException(
1053: // "No operations allowed after statement closed",
1054: // SQLError.SQL_STATE_GENERAL_ERROR);
1055: // }
1056: // } catch (SQLException sqlEx) {
1057: // checkAndFireConnectionError(sqlEx);
1058: // }
1059: // }
1060: //
1061: // public void setNClob(int parameterIndex, NClob value) throws SQLException {
1062: // try {
1063: // if (this.wrappedStmt != null) {
1064: // ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
1065: // value);
1066: // } else {
1067: // throw SQLError.createSQLException(
1068: // "No operations allowed after statement closed",
1069: // SQLError.SQL_STATE_GENERAL_ERROR);
1070: // }
1071: // } catch (SQLException sqlEx) {
1072: // checkAndFireConnectionError(sqlEx);
1073: // }
1074: // }
1075: //
1076: // public void setNClob(int parameterIndex, Reader reader) throws SQLException {
1077: // try {
1078: // if (this.wrappedStmt != null) {
1079: // ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
1080: // reader);
1081: // } else {
1082: // throw SQLError.createSQLException(
1083: // "No operations allowed after statement closed",
1084: // SQLError.SQL_STATE_GENERAL_ERROR);
1085: // }
1086: // } catch (SQLException sqlEx) {
1087: // checkAndFireConnectionError(sqlEx);
1088: // }
1089: // }
1090: //
1091: // public void setNClob(int parameterIndex, Reader reader, long length)
1092: // throws SQLException {
1093: // try {
1094: // if (this.wrappedStmt != null) {
1095: // ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
1096: // reader, length);
1097: // } else {
1098: // throw SQLError.createSQLException(
1099: // "No operations allowed after statement closed",
1100: // SQLError.SQL_STATE_GENERAL_ERROR);
1101: // }
1102: // } catch (SQLException sqlEx) {
1103: // checkAndFireConnectionError(sqlEx);
1104: // }
1105: // }
1106: //
1107: // public void setNString(int parameterIndex, String value)
1108: // throws SQLException {
1109: // try {
1110: // if (this.wrappedStmt != null) {
1111: // ((PreparedStatement) this.wrappedStmt).setNString(
1112: // parameterIndex, value);
1113: // } else {
1114: // throw SQLError.createSQLException(
1115: // "No operations allowed after statement closed",
1116: // SQLError.SQL_STATE_GENERAL_ERROR);
1117: // }
1118: // } catch (SQLException sqlEx) {
1119: // checkAndFireConnectionError(sqlEx);
1120: // }
1121: // }
1122: //
1123: // public void setRowId(int parameterIndex, RowId x) throws SQLException {
1124: // try {
1125: // if (this.wrappedStmt != null) {
1126: // ((PreparedStatement) this.wrappedStmt).setRowId(parameterIndex,
1127: // x);
1128: // } else {
1129: // throw SQLError.createSQLException(
1130: // "No operations allowed after statement closed",
1131: // SQLError.SQL_STATE_GENERAL_ERROR);
1132: // }
1133: // } catch (SQLException sqlEx) {
1134: // checkAndFireConnectionError(sqlEx);
1135: // }
1136: // }
1137: //
1138: // public void setSQLXML(int parameterIndex, SQLXML xmlObject)
1139: // throws SQLException {
1140: // try {
1141: // if (this.wrappedStmt != null) {
1142: // ((PreparedStatement) this.wrappedStmt).setSQLXML(
1143: // parameterIndex, xmlObject);
1144: // } else {
1145: // throw SQLError.createSQLException(
1146: // "No operations allowed after statement closed",
1147: // SQLError.SQL_STATE_GENERAL_ERROR);
1148: // }
1149: // } catch (SQLException sqlEx) {
1150: // checkAndFireConnectionError(sqlEx);
1151: // }
1152: // }
1153: //
1154: // public boolean isClosed() throws SQLException {
1155: // try {
1156: // if (this.wrappedStmt != null) {
1157: // return ((PreparedStatement) this.wrappedStmt).isClosed();
1158: // } else {
1159: // throw SQLError.createSQLException(
1160: // "No operations allowed after statement closed",
1161: // SQLError.SQL_STATE_GENERAL_ERROR);
1162: // }
1163: // } catch (SQLException sqlEx) {
1164: // checkAndFireConnectionError(sqlEx);
1165: // }
1166: //
1167: // return true;
1168: // }
1169: //
1170: // public boolean isPoolable() throws SQLException {
1171: // try {
1172: // if (this.wrappedStmt != null) {
1173: // return ((PreparedStatement) this.wrappedStmt).isPoolable();
1174: // } else {
1175: // throw SQLError.createSQLException(
1176: // "No operations allowed after statement closed",
1177: // SQLError.SQL_STATE_GENERAL_ERROR);
1178: // }
1179: // } catch (SQLException sqlEx) {
1180: // checkAndFireConnectionError(sqlEx);
1181: // }
1182: //
1183: // return false;
1184: // }
1185: //
1186: // public void setPoolable(boolean poolable) throws SQLException {
1187: // try {
1188: // if (this.wrappedStmt != null) {
1189: // ((PreparedStatement) this.wrappedStmt).setPoolable(poolable);
1190: // } else {
1191: // throw SQLError.createSQLException(
1192: // "No operations allowed after statement closed",
1193: // SQLError.SQL_STATE_GENERAL_ERROR);
1194: // }
1195: // } catch (SQLException sqlEx) {
1196: // checkAndFireConnectionError(sqlEx);
1197: // }
1198: // }
1199: //
1200: // public boolean isWrapperFor(Class arg0) throws SQLException {
1201: // throw new NotYetImplementedException();
1202: // }
1203: //
1204: // public Object unwrap(Class arg0) throws SQLException {
1205: // throw new NotYetImplementedException();
1206: // }
1207: }
|