1 package com.protomatter.jdbc.pool; 2 3 import java.io.*; 4 import java.sql.*; 5 import java.util.Map ; 6 import java.util.Calendar ; 7 8 import com.protomatter.syslog.Channel; 9 10 15 class CallableStatementWrapper 16 extends PreparedStatementWrapper 17 implements CallableStatement 18 { 19 private ConnectionWrapper connection = null; 20 private CallableStatement statement = null; 21 private boolean isClosed = false; 22 private Channel log = Channel.forPackage(CallableStatementWrapper.class); 23 24 public CallableStatementWrapper(ConnectionWrapper connection, CallableStatement statement) 25 { 26 super(connection, statement); 27 this.connection = connection; 28 this.statement = statement; 29 } 30 31 public CallableStatement getCallableStatement() 32 { 33 if (this.statement == null) 34 return null; 35 return this.statement; 36 } 37 38 private final void checkClosed() 39 throws SQLException 40 { 41 if (this.isClosed) 42 throw new SQLException("CallableStatement is already closed."); 43 } 44 45 public void registerOutParameter(int index, int type) 46 throws SQLException 47 { 48 checkClosed(); 49 callMethod(statement, "registerOutParameter", 50 new Class [] { Integer.TYPE, Integer.TYPE }, new Object [] { new Integer (index), new Integer (type) }); 51 } 52 53 public void registerOutParameter(int index, int type, int scale) 54 throws SQLException 55 { 56 checkClosed(); 57 callMethod(statement, "registerOutParameter", 58 new Class [] { Integer.TYPE, Integer.TYPE, Integer.TYPE }, 59 new Object [] { new Integer (index), new Integer (type), new Integer (scale) }); 60 } 61 62 public boolean wasNull() 63 throws SQLException 64 { 65 checkClosed(); 66 return callBooleanMethod(statement, "wasNull", new Class [0], new Object [0]); 67 } 68 69 public String getString(int index) 70 throws SQLException 71 { 72 checkClosed(); 73 return callStringMethod(statement, "getString", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 74 } 75 76 public boolean getBoolean(int index) 77 throws SQLException 78 { 79 checkClosed(); 80 return callBooleanMethod(statement, "getBoolean", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 81 } 82 83 public byte getByte(int index) 84 throws SQLException 85 { 86 checkClosed(); 87 return callByteMethod(statement, "getByte", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 88 } 89 90 public short getShort(int index) 91 throws SQLException 92 { 93 checkClosed(); 94 return callShortMethod(statement, "getShort", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 95 } 96 97 public int getInt(int index) 98 throws SQLException 99 { 100 checkClosed(); 101 return callIntMethod(statement, "getInt", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 102 } 103 104 public long getLong(int index) 105 throws SQLException 106 { 107 checkClosed(); 108 return callLongMethod(statement, "getLong", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 109 } 110 111 public float getFloat(int index) 112 throws SQLException 113 { 114 checkClosed(); 115 return callFloatMethod(statement, "getFloat", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 116 } 117 118 public double getDouble(int index) 119 throws SQLException 120 { 121 checkClosed(); 122 return callDoubleMethod(statement, "getDouble", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 123 } 124 125 public java.math.BigDecimal getBigDecimal(int index, int scale) 126 throws SQLException 127 { 128 checkClosed(); 129 return (java.math.BigDecimal )callMethod(statement, "getBigDecimal", 130 new Class [] { Integer.TYPE, Integer.TYPE }, 131 new Object [] { new Integer (index), new Integer (scale) }); 132 } 133 134 public byte[] getBytes(int index) 135 throws SQLException 136 { 137 checkClosed(); 138 return (byte[])callMethod(statement, "getBytes", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 139 } 140 141 public Date getDate(int index) 142 throws SQLException 143 { 144 checkClosed(); 145 return (Date)callMethod(statement, "getDate", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 146 } 147 148 public Time getTime(int index) 149 throws SQLException 150 { 151 checkClosed(); 152 return (Time)callMethod(statement, "getTime", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 153 } 154 155 public Timestamp getTimestamp(int index) 156 throws SQLException 157 { 158 checkClosed(); 159 return (Timestamp)callMethod(statement, "getTimestamp", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 160 } 161 162 public Object getObject(int index) 163 throws SQLException 164 { 165 checkClosed(); 166 return callMethod(statement, "getObject", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 167 } 168 169 public java.math.BigDecimal getBigDecimal(int index) 170 throws SQLException 171 { 172 checkClosed(); 173 return (java.math.BigDecimal )callMethod(statement, "getBigDecimal", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 174 } 175 176 public Object getObject(int index, Map map) 177 throws SQLException 178 { 179 checkClosed(); 180 return callMethod(statement, "getObject", new Class [] { Integer.TYPE, Map .class }, new Object [] { new Integer (index), map }); 181 } 182 183 public Ref getRef(int index) 184 throws SQLException 185 { 186 checkClosed(); 187 return (Ref)callMethod(statement, "getRef", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 188 } 189 190 public Blob getBlob(int index) 191 throws SQLException 192 { 193 checkClosed(); 194 return (Blob)callMethod(statement, "getBlob", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 195 } 196 197 public Clob getClob(int index) 198 throws SQLException 199 { 200 checkClosed(); 201 return (Clob)callMethod(statement, "getClob", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 202 } 203 204 public Array getArray(int index) 205 throws SQLException 206 { 207 checkClosed(); 208 return (Array)callMethod(statement, "getArray", new Class [] { Integer.TYPE }, new Object [] { new Integer (index) }); 209 } 210 211 public Date getDate(int index, Calendar cal) 212 throws SQLException 213 { 214 checkClosed(); 215 return (Date)callMethod(statement, "getDate", new Class [] { Integer.TYPE, Calendar .class }, 216 new Object [] { new Integer (index), cal }); 217 } 218 219 public Time getTime(int index, Calendar cal) 220 throws SQLException 221 { 222 checkClosed(); 223 return (Time)callMethod(statement, "getTime", new Class [] { Integer.TYPE, Calendar .class }, 224 new Object [] { new Integer (index), cal }); 225 } 226 227 public Timestamp getTimestamp(int index, Calendar cal) 228 throws SQLException 229 { 230 checkClosed(); 231 return (Timestamp)callMethod(statement, "getTimestamp", new Class [] { Integer.TYPE, Calendar .class }, 232 new Object [] { new Integer (index), cal }); 233 } 234 235 public void registerOutParameter(int index, int type, String typeName) 236 throws SQLException 237 { 238 checkClosed(); 239 this.statement.registerOutParameter(index, type, typeName); 240 callMethod(statement, "registerOutParameter", 241 new Class [] { Integer.TYPE, Integer.TYPE, String .class }, 242 new Object [] { new Integer (index), new Integer (type), typeName }); 243 } 244 } 245 | Popular Tags |