1 30 31 32 package org.hsqldb.jdbc; 33 34 import java.math.BigDecimal ; 35 import java.sql.CallableStatement ; 36 import java.sql.Date ; 37 import java.sql.Time ; 38 import java.sql.Timestamp ; 39 import java.sql.SQLException ; 40 import java.util.Calendar ; 41 42 import java.sql.Array ; 44 import java.sql.Blob ; 45 import java.sql.Clob ; 46 import java.sql.Ref ; 47 import java.util.Map ; 48 49 import org.hsqldb.HsqlException; 51 import org.hsqldb.Trace; 52 import org.hsqldb.lib.IntValueHashMap; 53 54 72 295 public class jdbcCallableStatement extends jdbcPreparedStatement 296 implements CallableStatement { 297 298 299 private IntValueHashMap parameterNameMap; 300 301 302 303 305 315 public jdbcCallableStatement(jdbcConnection c, String sql, 316 int type) 317 throws HsqlException, SQLException { 318 319 super(c, sql, type); 320 321 String [] names; 322 String name; 323 324 parameterNameMap = new IntValueHashMap(); 326 327 if (pmdDescriptor != null && pmdDescriptor.metaData != null) { 328 names = pmdDescriptor.metaData.colNames; 329 330 for (int i = 0; i < names.length; i++) { 331 name = names[i]; 332 333 if (name == null || name.length() == 0) { 335 continue; } 337 338 parameterNameMap.put(name, i); 339 } 340 } 341 } 342 343 351 int findParameterIndex(String parameterName) throws SQLException { 352 353 checkClosed(); 354 355 int index = parameterNameMap.get(parameterName, -1); 356 357 if (index >= 0) { 358 return index + 1; 359 } 360 361 throw Util.sqlException(Trace.COLUMN_NOT_FOUND, parameterName); 362 } 363 364 370 public void close() throws SQLException { 371 372 if (isClosed()) { 373 return; 374 } 375 376 parameterNameMap = null; 378 379 super.close(); 380 } 381 382 388 private void checkGetParameterIndex(int i) throws SQLException { 389 390 checkClosed(); 391 392 if (i < 1 || i > parameterModes.length) { 393 String msg = "Parameter index out of bounds: " + i; 394 395 throw Util.sqlException(Trace.INVALID_JDBC_ARGUMENT, msg); 396 } 397 414 } 415 416 423 441 442 444 481 public void registerOutParameter(int parameterIndex, 482 int sqlType) throws SQLException { 483 throw Util.notSupported(); 484 } 485 486 520 public void registerOutParameter(int parameterIndex, int sqlType, 521 int scale) throws SQLException { 522 registerOutParameter(parameterIndex, sqlType); 523 } 524 525 547 public boolean wasNull() throws SQLException { 548 throw Util.notSupported(); 549 } 550 551 582 public String getString(int parameterIndex) throws SQLException { 583 throw Util.notSupported(); 584 } 585 586 609 public boolean getBoolean(int parameterIndex) throws SQLException { 610 throw Util.notSupported(); 611 } 612 613 636 public byte getByte(int parameterIndex) throws SQLException { 637 throw Util.notSupported(); 638 } 639 640 663 public short getShort(int parameterIndex) throws SQLException { 664 throw Util.notSupported(); 665 } 666 667 690 public int getInt(int parameterIndex) throws SQLException { 691 throw Util.notSupported(); 692 } 693 694 717 public long getLong(int parameterIndex) throws SQLException { 718 throw Util.notSupported(); 719 } 720 721 744 public float getFloat(int parameterIndex) throws SQLException { 745 throw Util.notSupported(); 746 } 747 748 771 public double getDouble(int parameterIndex) throws SQLException { 772 throw Util.notSupported(); 773 } 774 775 802 803 public BigDecimal getBigDecimal(int parameterIndex, 805 int scale) throws SQLException { 806 throw Util.notSupported(); 807 } 808 809 811 834 public byte[] getBytes(int parameterIndex) throws SQLException { 835 throw Util.notSupported(); 836 } 837 838 860 public Date getDate(int parameterIndex) throws SQLException { 861 throw Util.notSupported(); 862 } 863 864 887 public Time getTime(int parameterIndex) throws SQLException { 888 throw Util.notSupported(); 889 } 890 891 914 public Timestamp getTimestamp(int parameterIndex) throws SQLException { 915 throw Util.notSupported(); 916 } 917 918 947 public Object getObject(int parameterIndex) throws SQLException { 948 throw Util.notSupported(); 949 } 950 951 953 979 public BigDecimal getBigDecimal(int parameterIndex) throws SQLException { 980 throw Util.notSupported(); 981 } 982 983 1014 public Object getObject(int parameterIndex, Map map) throws SQLException { 1015 throw Util.notSupported(); 1016 } 1017 1018 1044 public Ref getRef(int parameterIndex) throws SQLException { 1045 throw Util.notSupported(); 1046 } 1047 1048 1074 public Blob getBlob(int parameterIndex) throws SQLException { 1075 throw Util.notSupported(); 1076 } 1077 1078 1104 public Clob getClob(int parameterIndex) throws SQLException { 1105 throw Util.notSupported(); 1106 } 1107 1108 1134 public Array getArray(int parameterIndex) throws SQLException { 1135 throw Util.notSupported(); 1136 } 1137 1138 1171 public Date getDate(int parameterIndex, 1172 Calendar cal) throws SQLException { 1173 1174 throw Util.notSupported(); 1175 1176 } 1183 1184 1217 public Time getTime(int parameterIndex, 1218 Calendar cal) throws SQLException { 1219 1220 throw Util.notSupported(); 1221 1222 } 1229 1230 1263 public Timestamp getTimestamp(int parameterIndex, 1264 Calendar cal) throws SQLException { 1265 1266 throw Util.notSupported(); 1267 1268 } 1275 1276 1323 public void registerOutParameter(int parameterIndex, int sqlType, 1324 String typeName) throws SQLException { 1325 registerOutParameter(parameterIndex, sqlType); 1326 } 1327 1328 1330 1367 public void registerOutParameter(String parameterName, 1369 int sqlType) throws SQLException { 1370 registerOutParameter(findParameterIndex(parameterName), sqlType); 1371 } 1372 1373 1375 1409 public void registerOutParameter(String parameterName, int sqlType, 1411 int scale) throws SQLException { 1412 registerOutParameter(findParameterIndex(parameterName), sqlType); 1413 } 1414 1415 1417 1463 public void registerOutParameter(String parameterName, int sqlType, 1465 String typeName) throws SQLException { 1466 registerOutParameter(findParameterIndex(parameterName), sqlType); 1467 } 1468 1469 1471 1497 public java.net.URL getURL(int parameterIndex) throws SQLException { 1499 throw Util.notSupported(); 1500 } 1501 1502 1504 1528 public void setURL(String parameterName, 1530 java.net.URL val) throws SQLException { 1531 setURL(findParameterIndex(parameterName), val); 1532 } 1533 1534 1536 1556 public void setNull(String parameterName, 1558 int sqlType) throws SQLException { 1559 setNull(findParameterIndex(parameterName), sqlType); 1560 } 1561 1562 1564 1586 public void setBoolean(String parameterName, 1588 boolean x) throws SQLException { 1589 setBoolean(findParameterIndex(parameterName), x); 1590 } 1591 1592 1594 1615 public void setByte(String parameterName, byte x) throws SQLException { 1617 setByte(findParameterIndex(parameterName), x); 1618 } 1619 1620 1622 1643 public void setShort(String parameterName, short x) throws SQLException { 1645 setShort(findParameterIndex(parameterName), x); 1646 } 1647 1648 1650 1671 public void setInt(String parameterName, int x) throws SQLException { 1673 setInt(findParameterIndex(parameterName), x); 1674 } 1675 1676 1678 1699 public void setLong(String parameterName, long x) throws SQLException { 1701 setLong(findParameterIndex(parameterName), x); 1702 } 1703 1704 1706 1727 public void setFloat(String parameterName, float x) throws SQLException { 1729 setFloat(findParameterIndex(parameterName), x); 1730 } 1731 1732 1734 1755 public void setDouble(String parameterName, 1757 double x) throws SQLException { 1758 setDouble(findParameterIndex(parameterName), x); 1759 } 1760 1761 1763 1785 public void setBigDecimal(String parameterName, 1787 BigDecimal x) throws SQLException { 1788 setBigDecimal(findParameterIndex(parameterName), x); 1789 } 1790 1791 1793 1816 public void setString(String parameterName, 1818 String x) throws SQLException { 1819 setString(findParameterIndex(parameterName), x); 1820 } 1821 1822 1824 1847 public void setBytes(String parameterName, byte[] x) throws SQLException { 1849 setBytes(findParameterIndex(parameterName), x); 1850 } 1851 1852 1854 1876 public void setDate(String parameterName, Date x) throws SQLException { 1878 setDate(findParameterIndex(parameterName), x); 1879 } 1880 1881 1883 1904 public void setTime(String parameterName, Time x) throws SQLException { 1906 setTime(findParameterIndex(parameterName), x); 1907 } 1908 1909 1911 1933 public void setTimestamp(String parameterName, 1935 Timestamp x) throws SQLException { 1936 setTimestamp(findParameterIndex(parameterName), x); 1937 } 1938 1939 1941 1970 public void setAsciiStream(String parameterName, java.io.InputStream x, 1972 int length) throws SQLException { 1973 setAsciiStream(findParameterIndex(parameterName), x, length); 1974 } 1975 1976 1978 2006 public void setBinaryStream(String parameterName, java.io.InputStream x, 2008 int length) throws SQLException { 2009 setBinaryStream(findParameterIndex(parameterName), x, length); 2010 } 2011 2012 2014 2056 public void setObject(String parameterName, Object x, int targetSqlType, 2058 int scale) throws SQLException { 2059 setObject(findParameterIndex(parameterName), x, targetSqlType, scale); 2060 } 2061 2062 2064 2087 public void setObject(String parameterName, Object x, 2089 int targetSqlType) throws SQLException { 2090 setObject(findParameterIndex(parameterName), x, targetSqlType); 2091 } 2092 2093 2095 2139 public void setObject(String parameterName, 2141 Object x) throws SQLException { 2142 setObject(findParameterIndex(parameterName), x); 2143 } 2144 2145 2147 2177 public void setCharacterStream(String parameterName, 2179 java.io.Reader reader, 2180 int length) throws SQLException { 2181 setCharacterStream(findParameterIndex(parameterName), reader, length); 2182 } 2183 2184 2186 2215 public void setDate(String parameterName, Date x, 2217 Calendar cal) throws SQLException { 2218 setDate(findParameterIndex(parameterName), x, cal); 2219 } 2220 2221 2223 2252 public void setTime(String parameterName, Time x, 2254 Calendar cal) throws SQLException { 2255 setTime(findParameterIndex(parameterName), x, cal); 2256 } 2257 2258 2260 2290 public void setTimestamp(String parameterName, Timestamp x, 2292 Calendar cal) throws SQLException { 2293 setTimestamp(findParameterIndex(parameterName), x, cal); 2294 } 2295 2296 2298 2337 public void setNull(String parameterName, int sqlType, 2339 String typeName) throws SQLException { 2340 setNull(findParameterIndex(parameterName), sqlType, typeName); 2341 } 2342 2343 2345 2375 public String getString(String parameterName) throws SQLException { 2377 return getString(findParameterIndex(parameterName)); 2378 } 2379 2380 2382 2406 public boolean getBoolean(String parameterName) throws SQLException { 2408 return getBoolean(findParameterIndex(parameterName)); 2409 } 2410 2411 2413 2436 public byte getByte(String parameterName) throws SQLException { 2438 return getByte(findParameterIndex(parameterName)); 2439 } 2440 2441 2443 2466 public short getShort(String parameterName) throws SQLException { 2468 return getShort(findParameterIndex(parameterName)); 2469 } 2470 2471 2473 2496 public int getInt(String parameterName) throws SQLException { 2498 return getInt(findParameterIndex(parameterName)); 2499 } 2500 2501 2503 2526 public long getLong(String parameterName) throws SQLException { 2528 return getLong(findParameterIndex(parameterName)); 2529 } 2530 2531 2533 2556 public float getFloat(String parameterName) throws SQLException { 2558 return getFloat(findParameterIndex(parameterName)); 2559 } 2560 2561 2563 2586 public double getDouble(String parameterName) throws SQLException { 2588 return getDouble(findParameterIndex(parameterName)); 2589 } 2590 2591 2593 2617 public byte[] getBytes(String parameterName) throws SQLException { 2619 return getBytes(findParameterIndex(parameterName)); 2620 } 2621 2622 2624 2647 public Date getDate(String parameterName) throws SQLException { 2649 return getDate(findParameterIndex(parameterName)); 2650 } 2651 2652 2654 2677 public Time getTime(String parameterName) throws SQLException { 2679 return getTime(findParameterIndex(parameterName)); 2680 } 2681 2682 2684 2707 public Timestamp getTimestamp(String parameterName) throws SQLException { 2709 return getTimestamp(findParameterIndex(parameterName)); 2710 } 2711 2712 2714 2744 public Object getObject(String parameterName) throws SQLException { 2746 return getObject(findParameterIndex(parameterName)); 2747 } 2748 2749 2751 2775 public BigDecimal getBigDecimal(String parameterName) 2777 throws SQLException { 2778 return getBigDecimal(findParameterIndex(parameterName)); 2779 } 2780 2781 2783 2813 public Object getObject(String parameterName, 2815 Map map) throws SQLException { 2816 return getObject(findParameterIndex(parameterName), map); 2817 } 2818 2819 2821 2844 public Ref getRef(String parameterName) throws SQLException { 2846 return getRef(findParameterIndex(parameterName)); 2847 } 2848 2849 2851 2874 public Blob getBlob(String parameterName) throws SQLException { 2876 return getBlob(findParameterIndex(parameterName)); 2877 } 2878 2879 2881 2904 public Clob getClob(String parameterName) throws SQLException { 2906 return getClob(findParameterIndex(parameterName)); 2907 } 2908 2909 2911 2934 public Array getArray(String parameterName) throws SQLException { 2936 return getArray(findParameterIndex(parameterName)); 2937 } 2938 2939 2941 2972 public Date getDate(String parameterName, 2974 Calendar cal) throws SQLException { 2975 return getDate(findParameterIndex(parameterName), cal); 2976 } 2977 2978 2980 3011 public Time getTime(String parameterName, 3013 Calendar cal) throws SQLException { 3014 return getTime(findParameterIndex(parameterName), cal); 3015 } 3016 3017 3019 3051 public Timestamp getTimestamp(String parameterName, 3053 Calendar cal) throws SQLException { 3054 return getTimestamp(findParameterIndex(parameterName), cal); 3055 } 3056 3057 3059 3084 public java.net.URL getURL(String parameterName) throws SQLException { 3086 return getURL(findParameterIndex(parameterName)); 3087 } 3088 3089} 3091 | Popular Tags |