1 21 22 package org.apache.derby.impl.jdbc; 23 24 import java.math.BigDecimal ; 25 import java.sql.CallableStatement ; 26 import java.sql.SQLException ; 27 import java.sql.Date ; 28 import java.sql.Time ; 29 import java.sql.Timestamp ; 30 import java.sql.Types ; 31 32 33 import java.sql.Array ; 34 import java.sql.Blob ; 35 import java.sql.Clob ; 36 import java.sql.Ref ; 37 38 import java.net.URL ; 39 import java.util.Map ; 40 41 import java.io.ByteArrayInputStream ; 42 import java.io.InputStream ; 43 import java.io.InputStreamReader ; 44 import java.io.Reader ; 45 import java.io.StringReader ; 46 import java.io.UnsupportedEncodingException ; 47 48 import java.util.Calendar ; 49 50 import org.apache.derby.iapi.error.StandardException; 51 52 import org.apache.derby.iapi.services.io.StreamStorable; 53 import org.apache.derby.iapi.sql.conn.StatementContext; 54 import org.apache.derby.iapi.reference.JDBC30Translation; 55 import org.apache.derby.iapi.reference.SQLState; 56 import org.apache.derby.iapi.types.DataValueDescriptor; 57 58 import org.apache.derby.impl.jdbc.Util; 59 import org.apache.derby.impl.jdbc.EmbedConnection; 60 import org.apache.derby.impl.jdbc.EmbedResultSet; 61 62 63 71 public class EmbedCallableStatement20 72 extends org.apache.derby.impl.jdbc.EmbedCallableStatement 73 { 74 75 public EmbedCallableStatement20 (EmbedConnection conn, String sql, 81 int resultSetType, 82 int resultSetConcurrency, 83 int resultSetHoldability) 84 throws SQLException 85 { 86 super(conn, sql, resultSetType, resultSetConcurrency, resultSetHoldability); 87 } 88 89 95 105 public BigDecimal getBigDecimal(int parameterIndex) throws SQLException 106 { 107 checkStatus(); 108 try { 109 DataValueDescriptor dvd = getParms().getParameterForGet(parameterIndex-1); 110 if (wasNull = dvd.isNull()) 111 return null; 112 113 return org.apache.derby.iapi.types.SQLDecimal.getBigDecimal(dvd); 114 115 } catch (StandardException e) 116 { 117 throw EmbedResultSet.noStateChangeException(e); 118 } 119 } 120 121 122 134 public Object getObject (int i, java.util.Map map) throws SQLException 135 { 136 checkStatus(); 137 if( map == null) 138 throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map", 139 "java.sql.CallableStatement.getObject"); 140 if(!(map.isEmpty())) 141 throw Util.notImplemented(); 142 return getObject(i); 144 } 145 146 155 public Ref getRef (int i) throws SQLException { 156 throw Util.notImplemented(); 157 } 158 159 168 public Array getArray (int i) throws SQLException { 169 throw Util.notImplemented(); 170 } 171 172 173 174 181 182 191 public void setRef (int i, Ref x) throws SQLException { 192 throw Util.notImplemented(); 193 } 194 195 204 public void setArray (int i, Array x) throws SQLException { 205 throw Util.notImplemented(); 206 } 207 208 209 215 227 public void registerOutParameter(String parameterName, 228 int sqlType) 229 throws SQLException 230 { 231 throw Util.notImplemented(); 232 } 233 234 245 public void registerOutParameter(String parameterName, 246 int sqlType, String typeName) 247 throws SQLException 248 { 249 throw Util.notImplemented(); 250 } 251 252 264 public void registerOutParameter(String parameterName, 265 int sqlType, int scale) 266 throws SQLException 267 { 268 throw Util.notImplemented(); 269 } 270 271 282 public Ref getRef(String parameterName) 283 throws SQLException 284 { 285 throw Util.notImplemented(); 286 } 287 288 299 public Blob getBlob(String parameterName) 300 throws SQLException 301 { 302 throw Util.notImplemented(); 303 } 304 305 316 public Clob getClob(String parameterName) 317 throws SQLException 318 { 319 throw Util.notImplemented(); 320 } 321 322 333 public Array getArray(String parameterName) 334 throws SQLException 335 { 336 throw Util.notImplemented(); 337 } 338 339 348 public void setNull(String parameterName, int sqlType) 349 throws SQLException 350 { 351 throw Util.notImplemented(); 352 } 353 363 public void setNull(String parameterName, int sqlType, String typeName) 364 throws SQLException 365 { 366 throw Util.notImplemented(); 367 } 368 369 379 public void setBoolean(String parameterName, boolean x) 380 throws SQLException 381 { 382 throw Util.notImplemented(); 383 } 384 385 395 public boolean getBoolean(String parameterName) 396 throws SQLException 397 { 398 throw Util.notImplemented(); 399 } 400 401 411 public void setByte(String parameterName, byte x) 412 throws SQLException 413 { 414 throw Util.notImplemented(); 415 } 416 417 427 public byte getByte(String parameterName) 428 throws SQLException 429 { 430 throw Util.notImplemented(); 431 } 432 433 443 public void setShort(String parameterName, short x) 444 throws SQLException 445 { 446 throw Util.notImplemented(); 447 } 448 449 459 public short getShort(String parameterName) 460 throws SQLException 461 { 462 throw Util.notImplemented(); 463 } 464 465 475 public void setInt(String parameterName, int x) 476 throws SQLException 477 { 478 throw Util.notImplemented(); 479 } 480 481 491 public int getInt(String parameterName) 492 throws SQLException 493 { 494 throw Util.notImplemented(); 495 } 496 497 507 public void setLong(String parameterName, long x) 508 throws SQLException 509 { 510 throw Util.notImplemented(); 511 } 512 513 523 public long getLong(String parameterName) 524 throws SQLException 525 { 526 throw Util.notImplemented(); 527 } 528 529 539 public void setFloat(String parameterName, float x) 540 throws SQLException 541 { 542 throw Util.notImplemented(); 543 } 544 545 555 public float getFloat(String parameterName) 556 throws SQLException 557 { 558 throw Util.notImplemented(); 559 } 560 561 571 public void setDouble(String parameterName, double x) 572 throws SQLException 573 { 574 throw Util.notImplemented(); 575 } 576 577 587 public double getDouble(String parameterName) 588 throws SQLException 589 { 590 throw Util.notImplemented(); 591 } 592 593 603 public void setBigDecimal(String parameterName, BigDecimal x) 604 throws SQLException 605 { 606 throw Util.notImplemented(); 607 } 608 609 619 public BigDecimal getBigDecimal(String parameterName) 620 throws SQLException 621 { 622 throw Util.notImplemented(); 623 } 624 625 637 public void setString(String parameterName, String x) 638 throws SQLException 639 { 640 throw Util.notImplemented(); 641 } 642 643 653 public String getString(String parameterName) 654 throws SQLException 655 { 656 throw Util.notImplemented(); 657 } 658 659 671 public void setBytes(String parameterName, byte[] x) 672 throws SQLException 673 { 674 throw Util.notImplemented(); 675 } 676 677 687 public byte[] getBytes(String parameterName) 688 throws SQLException 689 { 690 throw Util.notImplemented(); 691 } 692 693 703 public void setDate(String parameterName, Date x) 704 throws SQLException 705 { 706 throw Util.notImplemented(); 707 } 708 709 720 public void setDate(String parameterName, Date x, Calendar cal) 721 throws SQLException 722 { 723 throw Util.notImplemented(); 724 } 725 726 735 public Date getDate(String parameterName) 736 throws SQLException 737 { 738 throw Util.notImplemented(); 739 } 740 741 752 public Date getDate(String parameterName, Calendar cal) 753 throws SQLException 754 { 755 throw Util.notImplemented(); 756 } 757 758 768 public void setTime(String parameterName, Time x) 769 throws SQLException 770 { 771 throw Util.notImplemented(); 772 } 773 774 783 public Time getTime(String parameterName) 784 throws SQLException 785 { 786 throw Util.notImplemented(); 787 } 788 789 800 public Time getTime(String parameterName, Calendar cal) 801 throws SQLException 802 { 803 throw Util.notImplemented(); 804 } 805 806 817 public void setTime(String parameterName, Time x, Calendar cal) 818 throws SQLException 819 { 820 throw Util.notImplemented(); 821 } 822 823 833 public void setTimestamp(String parameterName, Timestamp x) 834 throws SQLException 835 { 836 throw Util.notImplemented(); 837 } 838 839 850 public void setTimestamp(String parameterName, Timestamp x, Calendar cal) 851 throws SQLException 852 { 853 throw Util.notImplemented(); 854 } 855 856 865 public Timestamp getTimestamp(String parameterName) 866 throws SQLException 867 { 868 throw Util.notImplemented(); 869 } 870 871 882 public Timestamp getTimestamp(String parameterName, Calendar cal) 883 throws SQLException 884 { 885 throw Util.notImplemented(); 886 } 887 888 899 public void setAsciiStream(String parameterName, InputStream x, int length) 900 throws SQLException 901 { 902 throw Util.notImplemented(); 903 } 904 905 916 public void setBinaryStream(String parameterName, InputStream x, int length) 917 throws SQLException 918 { 919 throw Util.notImplemented(); 920 } 921 922 933 public void setCharacterStream(String parameterName, Reader reader, int length) 934 throws SQLException 935 { 936 throw Util.notImplemented(); 937 } 938 939 955 public void setObject(String parameterName, Object x, int targetSqlType, int scale) 956 throws SQLException 957 { 958 throw Util.notImplemented(); 959 } 960 961 970 public Object getObject(String parameterName) 971 throws SQLException 972 { 973 throw Util.notImplemented(); 974 } 975 976 987 public Object getObject(String parameterName, Map map) 988 throws SQLException 989 { 990 checkStatus(); 991 if( map == null) 992 throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map", 993 "java.sql.CallableStatement.getObject"); 994 if(!(map.isEmpty())) 995 throw Util.notImplemented(); 996 997 return getObject(parameterName); 999 } 1000 1001 1013 public void setObject(String parameterName, Object x, int targetSqlType) 1014 throws SQLException 1015 { 1016 throw Util.notImplemented(); 1017 } 1018 1019 1030 public void setObject(String parameterName, Object x) 1031 throws SQLException 1032 { 1033 throw Util.notImplemented(); 1034 } 1035 1036 1040 1049 public final void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { 1050 checkStatus(); 1051 try { 1052 1053 getParms().getParameterForSet(parameterIndex - 1).setBigDecimal(x); 1054 1055 } catch (Throwable t) { 1056 throw EmbedResultSet.noStateChangeException(t); 1057 } 1058 } 1059 1063 public final BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException 1064 { 1065 BigDecimal v = getBigDecimal(parameterIndex); 1066 if (v != null) 1067 v = v.setScale(scale, BigDecimal.ROUND_HALF_DOWN); 1068 return v; 1069 } 1070 1078 boolean setObjectConvert(int parameterIndex, Object x) throws SQLException 1079 { 1080 if (x instanceof BigDecimal ) { 1081 setBigDecimal(parameterIndex, (BigDecimal ) x); 1082 return true; 1083 } 1084 return false; 1085 } 1086 1087 1093 1105 public Reader getCharacterStream(int parameterIndex) 1106 throws SQLException { 1107 checkStatus(); 1108 switch (getParms().getParameterMode(parameterIndex)) { 1110 case JDBC30Translation.PARAMETER_MODE_IN: 1111 case JDBC30Translation.PARAMETER_MODE_UNKNOWN: 1112 throw newSQLException(SQLState.LANG_NOT_OUTPUT_PARAMETER, 1113 Integer.toString(parameterIndex)); 1114 } 1115 Reader reader = null; 1116 int paramType = getParameterJDBCType(parameterIndex); 1117 switch (paramType) { 1118 case Types.CHAR: 1120 case Types.VARCHAR: 1121 case Types.LONGVARCHAR: 1122 case Types.CLOB: 1123 boolean pushStack = false; 1124 Object syncObject = getConnectionSynchronization(); 1125 synchronized (syncObject) { 1126 try { 1127 DataValueDescriptor param = 1128 getParms().getParameterForGet(parameterIndex -1); 1129 if (param.isNull()) { 1130 break; 1131 } 1132 pushStack = true; 1133 setupContextStack(); 1134 1135 StreamStorable ss = (StreamStorable)param; 1136 InputStream stream = ss.returnStream(); 1137 if (stream == null) { 1138 reader = new StringReader (param.getString()); 1139 } else { 1140 reader = new UTF8Reader(stream, 0, this, syncObject); 1141 } 1142 } catch (Throwable t) { 1143 throw EmbedResultSet.noStateChangeException(t); 1144 } finally { 1145 if (pushStack) { 1146 restoreContextStack(); 1147 } 1148 } 1149 } break; 1151 1152 case Types.BINARY: 1156 case Types.VARBINARY: 1157 case Types.LONGVARBINARY: 1158 case Types.BLOB: 1159 try { 1160 InputStream is = getBinaryStream(parameterIndex); 1161 if (is != null) { 1162 reader = new InputStreamReader (is, "UTF-16BE"); 1163 } 1164 break; 1165 } catch (UnsupportedEncodingException uee) { 1166 throw newSQLException(uee.getMessage()); 1167 } 1168 1169 default: 1170 throw newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH, 1171 "java.io.Reader", Util.typeName(paramType)); 1172 } 1173 wasNull = (reader == null); 1175 return reader; 1176 } 1177 1178 1180 1188 private InputStream getBinaryStream(int parameterIndex) 1189 throws SQLException { 1190 int paramType = getParameterJDBCType(parameterIndex); 1191 switch (paramType) { 1192 case Types.BINARY: 1193 case Types.VARBINARY: 1194 case Types.LONGVARBINARY: 1195 case Types.BLOB: 1196 break; 1197 default: 1198 throw newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH, 1199 "java.io.InputStream", Util.typeName(paramType)); 1200 } 1201 1202 boolean pushStack = false; 1203 synchronized (getConnectionSynchronization()) { 1204 try { 1205 DataValueDescriptor param = 1206 getParms().getParameterForGet(parameterIndex -1); 1207 wasNull = param.isNull(); 1208 if (wasNull) { 1209 return null; 1210 } 1211 pushStack = true; 1212 setupContextStack(); 1213 1214 StreamStorable ss = (StreamStorable)param; 1215 InputStream stream = ss.returnStream(); 1216 if (stream == null) { 1217 stream = new ByteArrayInputStream (param.getBytes()); 1218 } else { 1219 stream = new BinaryToRawStream(stream, param); 1220 } 1221 return stream; 1222 } catch (Throwable t) { 1223 throw EmbedResultSet.noStateChangeException(t); 1224 } finally { 1225 if (pushStack) { 1226 restoreContextStack(); 1227 } 1228 } 1229 } } 1231} 1232 | Popular Tags |