1 30 31 32 package org.hsqldb.jdbc; 33 34 import java.io.IOException ; 35 import java.io.Serializable ; 36 import java.math.BigDecimal ; 37 import java.sql.Date ; 38 import java.sql.PreparedStatement ; 39 import java.sql.ResultSet ; 40 import java.sql.ResultSetMetaData ; 41 import java.sql.SQLException ; 42 import java.sql.Time ; 43 import java.sql.Timestamp ; 44 import java.util.Calendar ; 45 46 import java.sql.Array ; 48 import java.sql.Blob ; 49 import java.sql.Clob ; 50 import java.sql.Ref ; 51 52 import java.sql.ParameterMetaData ; 55 56 import org.hsqldb.Column; 58 import org.hsqldb.HsqlDateTime; 59 import org.hsqldb.HsqlException; 60 import org.hsqldb.Result; 61 import org.hsqldb.ResultConstants; 62 import org.hsqldb.Trace; 63 import org.hsqldb.Types; 64 import org.hsqldb.lib.ArrayUtil; 65 import org.hsqldb.lib.HsqlByteArrayOutputStream; 66 import org.hsqldb.lib.Iterator; 67 import org.hsqldb.lib.StringConverter; 68 import org.hsqldb.types.Binary; 69 import org.hsqldb.types.JavaObject; 70 71 87 203 public class jdbcPreparedStatement extends jdbcStatement 204 implements PreparedStatement { 205 206 207 protected Object [] parameterValues; 208 209 210 protected boolean[] parameterSet; 211 212 213 protected boolean[] parameterStream; 214 215 216 protected int[] parameterTypes; 217 218 219 protected int[] parameterModes; 220 221 222 protected int[] streamLengths; 223 224 225 protected boolean hasStreams; 226 227 230 protected Result rsmdDescriptor; 231 232 233 protected Result pmdDescriptor; 234 235 236 protected jdbcResultSetMetaData rsmd; 237 238 240 241 protected Object pmd; 242 243 244 protected String sql; 245 246 253 protected int statementID; 254 255 259 protected boolean isRowCount; 260 261 271 292 public void setEscapeProcessing(boolean enable) throws SQLException { 293 checkClosed(); 294 } 295 296 333 public boolean execute() throws SQLException { 334 335 checkClosed(); 336 connection.clearWarningsNoCheck(); 337 338 resultIn = null; 339 340 try { 341 resultOut.setMaxRows(maxRows); 342 resultOut.setParameterData(parameterValues); 343 344 resultIn = connection.sessionProxy.execute(resultOut); 345 } catch (HsqlException e) { 346 throw Util.sqlException(e); 347 } 348 349 if (resultIn.isError()) { 350 Util.throwError(resultIn); 351 } 352 353 return resultIn.isData(); 354 } 355 356 367 public ResultSet executeQuery() throws SQLException { 368 369 checkClosed(); 370 connection.clearWarningsNoCheck(); 371 checkIsRowCount(false); 372 checkParametersSet(); 373 374 resultIn = null; 375 376 try { 377 resultOut.setMaxRows(maxRows); 378 resultOut.setParameterData(parameterValues); 379 380 resultIn = connection.sessionProxy.execute(resultOut); 381 } catch (HsqlException e) { 382 throw Util.sqlException(e); 383 } 384 385 if (resultIn.isError()) { 386 Util.throwError(resultIn); 387 } else if (!resultIn.isData()) { 388 String msg = "Expected but did not recieve a result set"; 389 390 throw Util.sqlException(Trace.UNEXPECTED_EXCEPTION, msg); 391 } 392 393 return new jdbcResultSet(this, resultIn, connection.connProperties, 394 connection.isNetConn); 395 } 396 397 412 public int executeUpdate() throws SQLException { 413 414 checkClosed(); 415 connection.clearWarningsNoCheck(); 416 checkIsRowCount(true); 417 checkParametersSet(); 418 419 resultIn = null; 420 421 try { 422 resultOut.setParameterData(parameterValues); 423 424 resultIn = connection.sessionProxy.execute(resultOut); 425 } catch (HsqlException e) { 426 throw Util.sqlException(e); 427 } 428 429 if (resultIn.isError()) { 430 Util.throwError(resultIn); 431 } else if (resultIn.mode != ResultConstants.UPDATECOUNT) { 432 String msg = "Expected but did not recieve a row update count"; 433 434 throw Util.sqlException(Trace.UNEXPECTED_EXCEPTION, msg); 435 } 436 437 return resultIn.getUpdateCount(); 438 } 439 440 511 public int[] executeBatch() throws SQLException { 512 513 if (batchResultOut == null) { 514 batchResultOut = new Result(ResultConstants.BATCHEXECUTE, 515 parameterTypes, statementID); 516 } 517 518 return super.executeBatch(); 519 } 520 521 540 public void setNull(int paramIndex, int sqlType) throws SQLException { 541 setParameter(paramIndex, null); 542 } 543 544 564 public void setBoolean(int parameterIndex, 565 boolean x) throws SQLException { 566 567 Boolean b = x ? Boolean.TRUE 568 : Boolean.FALSE; 569 570 setParameter(parameterIndex, b); 571 } 572 573 584 public void setByte(int parameterIndex, byte x) throws SQLException { 585 setIntParameter(parameterIndex, x); 586 } 587 588 599 public void setShort(int parameterIndex, short x) throws SQLException { 600 setIntParameter(parameterIndex, x); 601 } 602 603 614 public void setInt(int parameterIndex, int x) throws SQLException { 615 setIntParameter(parameterIndex, x); 616 } 617 618 629 public void setLong(int parameterIndex, long x) throws SQLException { 630 setLongParameter(parameterIndex, x); 631 } 632 633 655 public void setFloat(int parameterIndex, float x) throws SQLException { 656 setDouble(parameterIndex, (double) x); 657 } 658 659 681 public void setDouble(int parameterIndex, double x) throws SQLException { 682 683 Double d = new Double (x); 684 685 setParameter(parameterIndex, d); 686 } 687 688 700 public void setBigDecimal(int parameterIndex, 701 BigDecimal x) throws SQLException { 702 setParameter(parameterIndex, x); 703 } 704 705 729 public void setString(int parameterIndex, String x) throws SQLException { 730 setParameter(parameterIndex, x); 731 } 732 733 756 public void setBytes(int paramIndex, byte[] x) throws SQLException { 757 setParameter(paramIndex, x); 758 } 759 760 771 public void setDate(int parameterIndex, Date x) throws SQLException { 772 setParameter(parameterIndex, x); 773 } 774 775 786 public void setTime(int parameterIndex, Time x) throws SQLException { 787 setParameter(parameterIndex, x); 788 } 789 790 802 public void setTimestamp(int parameterIndex, 803 Timestamp x) throws SQLException { 804 setParameter(parameterIndex, x); 805 } 806 807 839 public void setAsciiStream(int parameterIndex, java.io.InputStream x, 840 int length) throws SQLException { 841 842 checkSetParameterIndex(parameterIndex, true); 843 844 String s; 845 846 if (x == null) { 847 s = "input stream is null"; 848 849 throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, s); 850 } 851 852 try { 853 s = StringConverter.inputStreamToString(x, length); 854 855 setParameter(parameterIndex, s); 856 } catch (IOException e) { 857 throw Util.sqlException(Trace.INVALID_CHARACTER_ENCODING); 858 } 859 } 860 861 896 897 public void setUnicodeStream(int parameterIndex, java.io.InputStream x, 899 int length) throws SQLException { 900 901 checkSetParameterIndex(parameterIndex, true); 902 903 String msg = null; 904 905 if (x == null) { 906 msg = "input stream is null"; 907 } else if (length % 2 != 0) { 908 msg = "odd length argument"; 909 } 910 911 if (msg != null) { 912 throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, msg); 913 } 914 915 int chlen = length / 2; 916 int chread = 0; 917 StringBuffer sb = new StringBuffer (); 918 int hi; 919 int lo; 920 921 try { 922 for (; chread < chlen; chread++) { 923 hi = x.read(); 924 925 if (hi == -1) { 926 break; 927 } 928 929 lo = x.read(); 930 931 if (lo == -1) { 932 break; 933 } 934 935 sb.append((char) (hi << 8 | lo)); 936 } 937 } catch (IOException e) { 938 throw Util.sqlException(Trace.TRANSFER_CORRUPTED); 939 } 940 941 setParameter(parameterIndex, sb.toString()); 942 } 943 944 946 973 public void setBinaryStream(int parameterIndex, java.io.InputStream x, 974 int length) throws SQLException { 975 976 checkSetParameterIndex(parameterIndex, true); 977 978 if (x == null) { 979 throw Util.sqlException(Trace.error(Trace.INVALID_JDBC_ARGUMENT, 980 Trace.JDBC_NULL_STREAM)); 981 } 982 983 HsqlByteArrayOutputStream out = null; 984 985 try { 986 out = new HsqlByteArrayOutputStream(); 987 988 int size = 2048; 989 byte[] buff = new byte[size]; 990 991 for (int left = length; left > 0; ) { 992 int read = x.read(buff, 0, left > size ? size 993 : left); 994 995 if (read == -1) { 996 break; 997 } 998 999 out.write(buff, 0, read); 1000 1001 left -= read; 1002 } 1003 1004 setParameter(parameterIndex, out.toByteArray()); 1005 } catch (IOException e) { 1006 throw Util.sqlException(Trace.INPUTSTREAM_ERROR, e.toString()); 1007 } finally { 1008 if (out != null) { 1009 try { 1010 out.close(); 1011 } catch (IOException e) {} 1012 } 1013 } 1014 } 1015 1016 1029 public void clearParameters() throws SQLException { 1030 1031 checkClosed(); 1032 ArrayUtil.fillArray(parameterValues, null); 1033 ArrayUtil.clearArray(ArrayUtil.CLASS_CODE_BOOLEAN, parameterSet, 0, 1034 parameterSet.length); 1035 1036 if (parameterStream != null) { 1037 ArrayUtil.clearArray(ArrayUtil.CLASS_CODE_BOOLEAN, 1038 parameterStream, 0, parameterStream.length); 1039 } 1040 } 1041 1042 1045 1096 public void setObject(int parameterIndex, Object x, int targetSqlType, 1097 int scale) throws SQLException { 1098 1099 1100 setObject(parameterIndex, x); 1101 } 1102 1103 1126 public void setObject(int parameterIndex, Object x, 1127 int targetSqlType) throws SQLException { 1128 setObject(parameterIndex, x); 1129 } 1130 1131 1173 public void setObject(int parameterIndex, Object x) throws SQLException { 1174 setParameter(parameterIndex, x); 1175 } 1176 1177 1179 1198 public void addBatch() throws SQLException { 1200 1201 checkClosed(); 1202 1203 int len = parameterValues.length; 1204 Object [] bpValues = new Object [len]; 1205 1206 checkParametersSet(); 1207 System.arraycopy(parameterValues, 0, bpValues, 0, len); 1208 1209 if (batchResultOut == null) { 1210 batchResultOut = new Result(ResultConstants.BATCHEXECUTE, 1211 parameterTypes, statementID); 1212 } 1213 1214 batchResultOut.add(bpValues); 1215 } 1216 1217 1249 1250 public void setCharacterStream(int parameterIndex, java.io.Reader reader, 1254 int length) throws SQLException { 1255 1256 checkSetParameterIndex(parameterIndex, true); 1257 1258 if (reader == null) { 1259 String msg = "reader is null"; 1260 1261 throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, msg); 1262 } 1263 1264 final StringBuffer sb = new StringBuffer (); 1265 final int size = 2048; 1266 final char[] buff = new char[size]; 1267 1268 try { 1269 for (int left = length; left > 0; ) { 1270 final int read = reader.read(buff, 0, left > size ? size 1271 : left); 1272 1273 if (read == -1) { 1274 break; 1275 } 1276 1277 sb.append(buff, 0, read); 1278 1279 left -= read; 1280 } 1281 } catch (IOException e) { 1282 throw Util.sqlException(Trace.TRANSFER_CORRUPTED, e.toString()); 1283 } 1284 1285 setParameter(parameterIndex, sb.toString()); 1286 } 1287 1288 1311 public void setRef(int i, Ref x) throws SQLException { 1312 throw Util.notSupported(); 1313 } 1314 1315 1345 1346 public void setBlob(int i, Blob x) throws SQLException { 1349 1350 if (x instanceof jdbcBlob) { 1351 setParameter(i, ((jdbcBlob) x).data); 1352 1353 return; 1354 } else if (x == null) { 1355 setParameter(i, null); 1356 1357 return; 1358 } 1359 1360 checkSetParameterIndex(i, false); 1361 1362 final long length = x.length(); 1363 1364 if (length > Integer.MAX_VALUE) { 1365 String msg = "Maximum Blob input octet length exceeded: " 1366 + length; 1367 1368 throw Util.sqlException(Trace.INPUTSTREAM_ERROR, msg); 1369 } 1370 1371 HsqlByteArrayOutputStream out = null; 1372 1373 try { 1374 out = new HsqlByteArrayOutputStream(); 1375 1376 java.io.InputStream in = x.getBinaryStream(); 1377 int buffSize = 2048; 1378 byte[] buff = new byte[buffSize]; 1379 1380 for (int left = (int) length; left > 0; ) { 1381 int read = in.read(buff, 0, left > buffSize ? buffSize 1382 : left); 1383 1384 if (read == -1) { 1385 break; 1386 } 1387 1388 out.write(buff, 0, read); 1389 1390 left -= read; 1391 } 1392 1393 setParameter(i, out.toByteArray()); 1394 } catch (IOException e) { 1395 throw Util.sqlException(Trace.INPUTSTREAM_ERROR, e.toString()); 1396 } finally { 1397 if (out != null) { 1398 try { 1399 out.close(); 1400 } catch (IOException e) {} 1401 } 1402 } 1403 } 1404 1405 1407 1436 public void setClob(int i, Clob x) throws SQLException { 1439 1440 if (x instanceof jdbcClob) { 1441 setParameter(i, ((jdbcClob) x).data); 1442 1443 return; 1444 } else if (x == null) { 1445 setParameter(i, null); 1446 1447 return; 1448 } 1449 1450 checkSetParameterIndex(i, false); 1451 1452 final long length = x.length(); 1453 1454 if (length > Integer.MAX_VALUE) { 1455 String msg = "Max Clob input character length exceeded: " 1456 + length; 1457 1458 throw Util.sqlException(Trace.INPUTSTREAM_ERROR, msg); 1459 } 1460 1461 java.io.Reader reader = x.getCharacterStream(); 1462 final StringBuffer sb = new StringBuffer (); 1463 final int size = 2048; 1464 final char[] buff = new char[size]; 1465 1466 try { 1467 for (int left = (int) length; left > 0; ) { 1468 final int read = reader.read(buff, 0, left > size ? size 1469 : left); 1470 1471 if (read == -1) { 1472 break; 1473 } 1474 1475 sb.append(buff, 0, read); 1476 1477 left -= read; 1478 } 1479 } catch (IOException e) { 1480 throw Util.sqlException(Trace.TRANSFER_CORRUPTED, e.toString()); 1481 } 1482 1483 setParameter(i, sb.toString()); 1484 } 1485 1486 1488 1511 public void setArray(int i, Array x) throws SQLException { 1512 throw Util.notSupported(); 1513 } 1514 1515 1550 1551 public ResultSetMetaData getMetaData() throws SQLException { 1553 1554 checkClosed(); 1555 1556 if (isRowCount) { 1557 return null; 1558 } 1559 1560 if (rsmd == null) { 1561 rsmd = new jdbcResultSetMetaData(rsmdDescriptor, 1562 connection.connProperties); 1563 } 1564 1565 return rsmd; 1566 } 1567 1568 1589 1590 public void setDate(int parameterIndex, Date x, 1593 Calendar cal) throws SQLException { 1594 1595 String s; 1596 1597 try { 1598 s = HsqlDateTime.getDateString(x, cal); 1599 } catch (Exception e) { 1600 throw Util.sqlException(Trace.INVALID_ESCAPE, e.toString()); 1601 } 1602 1603 setParameter(parameterIndex, s); 1604 } 1605 1606 1627 1628 public void setTime(int parameterIndex, Time x, 1631 Calendar cal) throws SQLException { 1632 1633 String s; 1634 1635 try { 1636 s = HsqlDateTime.getTimeString(x, cal); 1637 } catch (Exception e) { 1638 throw Util.sqlException(Trace.INVALID_ESCAPE, e.toString()); 1639 } 1640 1641 setParameter(parameterIndex, s); 1642 } 1643 1644 1664 1665 public void setTimestamp(int parameterIndex, Timestamp x, 1668 Calendar cal) throws SQLException { 1669 1670 checkSetParameterIndex(parameterIndex, false); 1671 1672 if (cal != null && x != null) { 1673 int ns = x.getNanos(); 1674 1675 x = new Timestamp (HsqlDateTime.getTimeInMillis(x, cal, null)); 1676 1677 x.setNanos(ns); 1678 } 1679 1680 setParameter(parameterIndex, x); 1681 } 1682 1683 1721 public void setNull(int paramIndex, int sqlType, 1722 String typeName) throws SQLException { 1723 setParameter(paramIndex, null); 1724 } 1725 1726 1728 1749 public void setURL(int parameterIndex, 1751 java.net.URL x) throws SQLException { 1752 throw Util.notSupported(); 1753 } 1754 1755 1757 1778 public ParameterMetaData getParameterMetaData() throws SQLException { 1781 1782 checkClosed(); 1783 1784 if (pmd == null) { 1785 pmd = new jdbcParameterMetaData(pmdDescriptor); 1786 } 1787 1788 return (ParameterMetaData ) pmd; 1790 } 1791 1792 1795 1807 jdbcPreparedStatement(jdbcConnection c, String sql, 1808 int type) throws HsqlException, SQLException { 1809 1810 super(c, type); 1811 1812 sql = c.nativeSQL(sql); 1813 1814 resultOut.setResultType(ResultConstants.SQLPREPARE); 1815 resultOut.setMainString(sql); 1816 1817 Result in = connection.sessionProxy.execute(resultOut); 1818 1819 if (in.isError()) { 1820 Util.throwError(in); 1821 } 1822 1823 Iterator i; 1860 1861 i = in.iterator(); 1862 1863 try { 1864 Object [] row; 1865 1866 row = (Object []) i.next(); 1868 statementID = ((Result) row[0]).getStatementID(); 1869 1870 row = (Object []) i.next(); 1872 rsmdDescriptor = (Result) row[0]; 1873 isRowCount = rsmdDescriptor.mode == ResultConstants.UPDATECOUNT; 1874 1875 row = (Object []) i.next(); 1877 pmdDescriptor = (Result) row[0]; 1878 parameterTypes = pmdDescriptor.metaData.getParameterTypes(); 1879 parameterValues = new Object [parameterTypes.length]; 1880 parameterSet = new boolean[parameterTypes.length]; 1881 parameterModes = pmdDescriptor.metaData.paramMode; 1882 } catch (Exception e) { 1883 throw Trace.error(Trace.GENERAL_ERROR, e.toString()); 1884 } 1885 1886 resultOut = new Result(ResultConstants.SQLEXECUTE, parameterTypes, 1887 statementID); 1888 1889 this.sql = sql; 1891 } 1892 1893 1902 protected void checkIsRowCount(boolean yes) throws SQLException { 1903 1904 if (yes != isRowCount) { 1905 int msg = yes ? Trace.JDBC_STATEMENT_NOT_ROW_COUNT 1906 : Trace.JDBC_STATEMENT_NOT_RESULTSET; 1907 1908 throw Util.sqlException(msg); 1909 } 1910 } 1911 1912 1919 protected void checkSetParameterIndex(int i, 1920 boolean isStream) 1921 throws SQLException { 1922 1923 int mode; 1924 String msg; 1925 1926 checkClosed(); 1927 1928 if (i < 1 || i > parameterValues.length) { 1929 msg = "parameter index out of range: " + i; 1930 1931 throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, msg); 1932 } 1933 1934 if (isStream) { 1935 if (parameterStream == null) { 1936 parameterStream = new boolean[parameterTypes.length]; 1937 } 1938 1939 parameterStream[i - 1] = true; 1940 parameterSet[i - 1] = false; 1941 } else { 1942 parameterSet[i - 1] = true; 1943 } 1944 1959 } 1960 1961 1969 private void checkParametersSet() throws SQLException { 1970 ; 1971 } 1972 1973 1995 1996 2006 private void setParameter(int i, Object o) throws SQLException { 2007 2008 checkSetParameterIndex(i, false); 2009 2010 i--; 2011 2012 if (o == null) { 2013 parameterValues[i] = null; 2014 2015 return; 2016 } 2017 2018 int outType = parameterTypes[i]; 2019 2020 try { 2021 switch (outType) { 2022 2023 case Types.OTHER : 2024 o = new JavaObject((Serializable ) o); 2025 break; 2026 2027 case Types.BINARY : 2028 case Types.VARBINARY : 2029 case Types.LONGVARBINARY : 2030 if (!(o instanceof byte[])) { 2031 throw Util.sqlException( 2032 Trace.error(Trace.INVALID_CONVERSION)); 2033 } 2034 2035 o = new Binary((byte[]) o, !connection.isNetConn); 2036 break; 2037 2038 case Types.DATE : 2039 if (o instanceof java.util.Date ) { 2040 long t = HsqlDateTime.getNormalisedDate( 2041 ((java.util.Date ) o).getTime()); 2042 2043 o = new Date (t); 2044 } else { 2045 o = Column.convertObject(o, outType); 2046 } 2047 break; 2048 2049 case Types.TIME : 2050 if (o instanceof java.util.Date ) { 2051 long m = HsqlDateTime.getNormalisedTime( 2052 ((java.util.Date ) o).getTime()); 2053 2054 o = new Time (m); 2055 } else { 2056 o = Column.convertObject(o, outType); 2057 } 2058 break; 2059 2060 case Types.TIMESTAMP : 2061 if (o instanceof Timestamp ) { 2062 long m = ((Timestamp ) o).getTime(); 2063 int n = ((Timestamp ) o).getNanos(); 2064 2065 o = new Timestamp (m); 2066 2067 ((Timestamp ) o).setNanos(n); 2068 } else { 2069 o = Column.convertObject(o, outType); 2070 } 2071 break; 2072 2073 default : 2074 o = Column.convertObject(o, outType); 2075 break; 2076 } 2077 } catch (HsqlException e) { 2078 Util.throwError(e); 2079 } 2080 2081 parameterValues[i] = o; 2082 } 2083 2084 2090 private void setIntParameter(int i, int value) throws SQLException { 2091 2092 checkSetParameterIndex(i, false); 2093 2094 int outType = parameterTypes[i - 1]; 2095 2096 switch (outType) { 2097 2098 case Types.TINYINT : 2099 case Types.SMALLINT : 2100 case Types.INTEGER : 2101 Object o = new Integer (value); 2102 2103 parameterValues[i - 1] = o; 2104 break; 2105 2106 default : 2107 setLongParameter(i, value); 2108 } 2109 } 2110 2111 2119 private void setLongParameter(int i, long value) throws SQLException { 2120 2121 checkSetParameterIndex(i, false); 2122 2123 int outType = parameterTypes[i - 1]; 2124 2125 switch (outType) { 2126 2127 case Types.BIGINT : 2128 Object o = new Long (value); 2129 2130 parameterValues[i - 1] = o; 2131 break; 2132 2133 case Types.BINARY : 2134 case Types.OTHER : 2135 throw Util.sqlException( 2136 Trace.error(Trace.INVALID_CONVERSION)); 2137 default : 2138 setParameter(i, new Long (value)); 2139 } 2140 } 2141 2142 2149 public void addBatch(String sql) throws SQLException { 2150 throw Util.notSupported(); 2151 } 2152 2153 2161 public ResultSet executeQuery(String sql) throws SQLException { 2162 throw Util.notSupported(); 2163 } 2164 2165 2173 public boolean execute(String sql) throws SQLException { 2174 throw Util.notSupported(); 2175 } 2176 2177 2185 public int executeUpdate(String sql) throws SQLException { 2186 throw Util.notSupported(); 2187 } 2188 2189 2195 public synchronized void close() throws SQLException { 2196 2197 if (isClosed()) { 2198 return; 2199 } 2200 2201 HsqlException he = null; 2202 2203 try { 2204 2205 if (!connection.isClosed) { 2209 connection.sessionProxy.execute( 2210 Result.newFreeStmtRequest(statementID)); 2211 } 2212 } catch (HsqlException e) { 2213 he = e; 2214 } 2215 2216 parameterValues = null; 2217 parameterSet = null; 2218 parameterStream = null; 2219 parameterTypes = null; 2220 parameterModes = null; 2221 rsmdDescriptor = null; 2222 pmdDescriptor = null; 2223 rsmd = null; 2224 pmd = null; 2225 2226 super.close(); 2227 2228 if (he != null) { 2229 throw Util.sqlException(he); 2230 } 2231 } 2232 2233 2246 public String toString() { 2247 2248 StringBuffer sb = new StringBuffer (); 2249 String sql; 2250 Object [] pv; 2251 2252 sb.append(super.toString()); 2253 2254 sql = this.sql; 2255 pv = parameterValues; 2256 2257 if (sql == null || pv == null) { 2258 sb.append("[closed]"); 2259 2260 return sb.toString(); 2261 } 2262 2263 sb.append("[sql=[").append(sql).append("]"); 2264 2265 if (pv.length > 0) { 2266 sb.append(", parameters=["); 2267 2268 for (int i = 0; i < pv.length; i++) { 2269 sb.append('['); 2270 sb.append(pv[i]); 2271 sb.append("], "); 2272 } 2273 2274 sb.setLength(sb.length() - 2); 2275 sb.append(']'); 2276 } 2277 2278 sb.append(']'); 2279 2280 return sb.toString(); 2281 } 2282} 2283 | Popular Tags |