| 1 |
package jp.co.powerbeans.jdbcdebug.sql; |
| 2 |
|
| 3 |
import java.io.InputStream; |
| 4 |
import java.io.Reader; |
| 5 |
import java.math.BigDecimal; |
| 6 |
import java.net.URL; |
| 7 |
import java.sql.Array; |
| 8 |
import java.sql.Blob; |
| 9 |
import java.sql.Clob; |
| 10 |
import java.sql.Connection; |
| 11 |
import java.sql.Date; |
| 12 |
import java.sql.NClob; |
| 13 |
import java.sql.ParameterMetaData; |
| 14 |
import java.sql.Ref; |
| 15 |
import java.sql.ResultSet; |
| 16 |
import java.sql.ResultSetMetaData; |
| 17 |
import java.sql.RowId; |
| 18 |
import java.sql.SQLException; |
| 19 |
import java.sql.SQLWarning; |
| 20 |
import java.sql.SQLXML; |
| 21 |
import java.sql.Time; |
| 22 |
import java.sql.Timestamp; |
| 23 |
import java.util.ArrayList; |
| 24 |
import java.util.Calendar; |
| 25 |
import java.util.HashMap; |
| 26 |
import java.util.Iterator; |
| 27 |
|
| 28 |
import jp.co.powerbeans.jdbcdebug.util.Log; |
| 29 |
import jp.co.powerbeans.jdbcdebug.util.Survey; |
| 30 |
|
| 31 |
|
| 32 |
/** |
| 33 |
* <p>タイトル: PreparedStatement</p> |
| 34 |
* <p>説明: </p> |
| 35 |
* <p>Created on 2003/10/01</p> |
| 36 |
* @author 門田明彦 |
| 37 |
* @version $Revision: 1.1 $ |
| 38 |
*/ |
| 39 |
public class PreparedStatement implements java.sql.PreparedStatement { |
| 40 |
|
| 41 |
/** 実 java.sql.PreparedStatement */ |
| 42 |
private java.sql.PreparedStatement st; |
| 43 |
|
| 44 |
/** オリジナル SQL */ |
| 45 |
private String sql; |
| 46 |
|
| 47 |
/** バッチSQL */ |
| 48 |
private ArrayList<String> batchSqlList = new ArrayList<String>(); |
| 49 |
|
| 50 |
/** パラメータマップ key:parameterIndex(1.2..), value:object of value */ |
| 51 |
private HashMap paramMap = new HashMap(); |
| 52 |
|
| 53 |
|
| 54 |
/** |
| 55 |
* コンストラクタ |
| 56 |
* @param statement |
| 57 |
* @param sql |
| 58 |
*/ |
| 59 |
PreparedStatement(java.sql.PreparedStatement statement, String sql) { |
| 60 |
|
| 61 |
st = statement; |
| 62 |
this.sql = sql; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* コンストラクタ |
| 67 |
*/ |
| 68 |
private PreparedStatement() { |
| 69 |
super(); |
| 70 |
} |
| 71 |
|
| 72 |
/* (non-Javadoc) |
| 73 |
* @see java.sql.PreparedStatement#addBatch() |
| 74 |
*/ |
| 75 |
public void addBatch() throws SQLException { |
| 76 |
st.addBatch(); |
| 77 |
batchSqlList.add(sql); |
| 78 |
} |
| 79 |
|
| 80 |
/* (non-Javadoc) |
| 81 |
* @see java.sql.PreparedStatement#clearParameters() |
| 82 |
*/ |
| 83 |
public void clearParameters() throws SQLException { |
| 84 |
st.clearParameters(); |
| 85 |
} |
| 86 |
|
| 87 |
/* (non-Javadoc) |
| 88 |
* @see java.sql.PreparedStatement#execute() |
| 89 |
*/ |
| 90 |
public boolean execute() throws SQLException { |
| 91 |
|
| 92 |
try { |
| 93 |
Survey s = new Survey(); |
| 94 |
boolean r = st.execute(); |
| 95 |
Log.printlnSqlLog("execute " + sql, s.doEnd(), paramMap); |
| 96 |
return r; |
| 97 |
} catch (SQLException e) { |
| 98 |
Log.printlnSqlExceptionLog("execute " + sql, e); |
| 99 |
throw e; |
| 100 |
} |
| 101 |
|
| 102 |
// long s = System.currentTimeMillis(); |
| 103 |
// boolean r = st.execute(); |
| 104 |
// Log.println("execute " + sql, s, System.currentTimeMillis()); |
| 105 |
// return r; |
| 106 |
|
| 107 |
// return st.execute(); |
| 108 |
} |
| 109 |
|
| 110 |
/* (non-Javadoc) |
| 111 |
* @see java.sql.PreparedStatement#executeQuery() |
| 112 |
*/ |
| 113 |
public ResultSet executeQuery() throws SQLException { |
| 114 |
|
| 115 |
try { |
| 116 |
Survey s = new Survey(); |
| 117 |
ResultSet r = st.executeQuery(); |
| 118 |
Log.printlnSqlLog("executeQuery " + sql, s.doEnd(), paramMap); |
| 119 |
return r; |
| 120 |
} catch (SQLException e) { |
| 121 |
Log.printlnSqlExceptionLog("executeQuery " + sql, e); |
| 122 |
throw e; |
| 123 |
} |
| 124 |
|
| 125 |
// Log.println("executeQuery " + sql); |
| 126 |
// return st.executeQuery(); |
| 127 |
} |
| 128 |
|
| 129 |
/* (non-Javadoc) |
| 130 |
* @see java.sql.PreparedStatement#executeUpdate() |
| 131 |
*/ |
| 132 |
public int executeUpdate() throws SQLException { |
| 133 |
|
| 134 |
try { |
| 135 |
Survey s = new Survey(); |
| 136 |
int r = st.executeUpdate(); |
| 137 |
Log.printlnSqlLog("executeUpdate " + sql, s.doEnd(), paramMap); |
| 138 |
return r; |
| 139 |
} catch (SQLException e) { |
| 140 |
Log.printlnSqlExceptionLog("executeUpdate " + sql, e); |
| 141 |
throw e; |
| 142 |
} |
| 143 |
|
| 144 |
// Log.println("executeUpdate " + sql); |
| 145 |
// return st.executeUpdate(); |
| 146 |
} |
| 147 |
|
| 148 |
/* (non-Javadoc) |
| 149 |
* @see java.sql.PreparedStatement#getMetaData() |
| 150 |
*/ |
| 151 |
public ResultSetMetaData getMetaData() throws SQLException { |
| 152 |
return st.getMetaData(); |
| 153 |
} |
| 154 |
|
| 155 |
/* (non-Javadoc) |
| 156 |
* @see java.sql.PreparedStatement#getParameterMetaData() |
| 157 |
*/ |
| 158 |
public ParameterMetaData getParameterMetaData() throws SQLException { |
| 159 |
return st.getParameterMetaData(); |
| 160 |
} |
| 161 |
|
| 162 |
/* (non-Javadoc) |
| 163 |
* @see java.sql.PreparedStatement#setArray(int, java.sql.Array) |
| 164 |
*/ |
| 165 |
public void setArray(int i, Array x) throws SQLException { |
| 166 |
st.setArray(i, x); |
| 167 |
// AMS paramPut |
| 168 |
} |
| 169 |
|
| 170 |
/* (non-Javadoc) |
| 171 |
* @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, int) |
| 172 |
*/ |
| 173 |
public void setAsciiStream(int parameterIndex, InputStream x, int length) |
| 174 |
throws SQLException { |
| 175 |
st.setAsciiStream(parameterIndex, x, length); |
| 176 |
// AMS paramPut |
| 177 |
} |
| 178 |
|
| 179 |
/* (non-Javadoc) |
| 180 |
* @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal) |
| 181 |
*/ |
| 182 |
public void setBigDecimal(int parameterIndex, BigDecimal x) |
| 183 |
throws SQLException { |
| 184 |
st.setBigDecimal(parameterIndex, x); |
| 185 |
putParam(parameterIndex, (Object)x); |
| 186 |
} |
| 187 |
|
| 188 |
/* (non-Javadoc) |
| 189 |
* @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, int) |
| 190 |
*/ |
| 191 |
public void setBinaryStream(int parameterIndex, InputStream x, int length) |
| 192 |
throws SQLException { |
| 193 |
st.setBinaryStream(parameterIndex, x, length); |
| 194 |
// AMS paramPut |
| 195 |
} |
| 196 |
|
| 197 |
/* (non-Javadoc) |
| 198 |
* @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob) |
| 199 |
*/ |
| 200 |
public void setBlob(int i, Blob x) throws SQLException { |
| 201 |
st.setBlob(i, x); |
| 202 |
putParam(i, x); |
| 203 |
} |
| 204 |
|
| 205 |
/* (non-Javadoc) |
| 206 |
* @see java.sql.PreparedStatement#setBoolean(int, boolean) |
| 207 |
*/ |
| 208 |
public void setBoolean(int parameterIndex, boolean x) throws SQLException { |
| 209 |
st.setBoolean(parameterIndex, x); |
| 210 |
putParam(parameterIndex, x ? Boolean.TRUE : Boolean.FALSE); |
| 211 |
} |
| 212 |
|
| 213 |
/* (non-Javadoc) |
| 214 |
* @see java.sql.PreparedStatement#setByte(int, byte) |
| 215 |
*/ |
| 216 |
public void setByte(int parameterIndex, byte x) throws SQLException { |
| 217 |
st.setByte(parameterIndex, x); |
| 218 |
putParam(parameterIndex, new Byte(x)); |
| 219 |
} |
| 220 |
|
| 221 |
/* (non-Javadoc) |
| 222 |
* @see java.sql.PreparedStatement#setBytes(int, byte[]) |
| 223 |
*/ |
| 224 |
public void setBytes(int parameterIndex, byte[] x) throws SQLException { |
| 225 |
st.setBytes(parameterIndex, x); |
| 226 |
putParam(parameterIndex, x); |
| 227 |
} |
| 228 |
|
| 229 |
/* (non-Javadoc) |
| 230 |
* @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int) |
| 231 |
*/ |
| 232 |
public void setCharacterStream( |
| 233 |
int parameterIndex, |
| 234 |
Reader reader, |
| 235 |
int length) |
| 236 |
throws SQLException { |
| 237 |
st.setCharacterStream(parameterIndex, reader, length); |
| 238 |
// AMS paramPut |
| 239 |
} |
| 240 |
|
| 241 |
/* (non-Javadoc) |
| 242 |
* @see java.sql.PreparedStatement#setClob(int, java.sql.Clob) |
| 243 |
*/ |
| 244 |
public void setClob(int i, Clob x) throws SQLException { |
| 245 |
st.setClob(i, x); |
| 246 |
putParam(i, x); |
| 247 |
} |
| 248 |
|
| 249 |
/* (non-Javadoc) |
| 250 |
* @see java.sql.PreparedStatement#setDate(int, java.sql.Date, java.util.Calendar) |
| 251 |
*/ |
| 252 |
public void setDate(int parameterIndex, Date x, Calendar cal) |
| 253 |
throws SQLException { |
| 254 |
st.setDate(parameterIndex, x, cal); |
| 255 |
putParam(parameterIndex, x); |
| 256 |
} |
| 257 |
|
| 258 |
/* (non-Javadoc) |
| 259 |
* @see java.sql.PreparedStatement#setDate(int, java.sql.Date) |
| 260 |
*/ |
| 261 |
public void setDate(int parameterIndex, Date x) throws SQLException { |
| 262 |
st.setDate(parameterIndex, x); |
| 263 |
putParam(parameterIndex, x); |
| 264 |
} |
| 265 |
|
| 266 |
/* (non-Javadoc) |
| 267 |
* @see java.sql.PreparedStatement#setDouble(int, double) |
| 268 |
*/ |
| 269 |
public void setDouble(int parameterIndex, double x) throws SQLException { |
| 270 |
st.setDouble(parameterIndex, x); |
| 271 |
putParam(parameterIndex, new Double(x)); |
| 272 |
} |
| 273 |
|
| 274 |
/* (non-Javadoc) |
| 275 |
* @see java.sql.PreparedStatement#setFloat(int, float) |
| 276 |
*/ |
| 277 |
public void setFloat(int parameterIndex, float x) throws SQLException { |
| 278 |
st.setFloat(parameterIndex, x); |
| 279 |
putParam(parameterIndex, new Float(x)); |
| 280 |
} |
| 281 |
|
| 282 |
/* (non-Javadoc) |
| 283 |
* @see java.sql.PreparedStatement#setInt(int, int) |
| 284 |
*/ |
| 285 |
public void setInt(int parameterIndex, int x) throws SQLException { |
| 286 |
st.setInt(parameterIndex, x); |
| 287 |
putParam(parameterIndex, new Integer(x)); |
| 288 |
} |
| 289 |
|
| 290 |
/* (non-Javadoc) |
| 291 |
* @see java.sql.PreparedStatement#setLong(int, long) |
| 292 |
*/ |
| 293 |
public void setLong(int parameterIndex, long x) throws SQLException { |
| 294 |
st.setLong(parameterIndex, x); |
| 295 |
putParam(parameterIndex, new Long(x)); |
| 296 |
} |
| 297 |
|
| 298 |
/* (non-Javadoc) |
| 299 |
* @see java.sql.PreparedStatement#setNull(int, int, java.lang.String) |
| 300 |
*/ |
| 301 |
public void setNull(int paramIndex, int sqlType, String typeName) |
| 302 |
throws SQLException { |
| 303 |
st.setNull(paramIndex, sqlType, typeName); |
| 304 |
putParam(paramIndex, "null(" + sqlType + ")"); |
| 305 |
} |
| 306 |
|
| 307 |
/* (non-Javadoc) |
| 308 |
* @see java.sql.PreparedStatement#setNull(int, int) |
| 309 |
*/ |
| 310 |
public void setNull(int parameterIndex, int sqlType) throws SQLException { |
| 311 |
st.setNull(parameterIndex, sqlType); |
| 312 |
putParam(parameterIndex, "null(" + sqlType + ")"); |
| 313 |
} |
| 314 |
|
| 315 |
/* (non-Javadoc) |
| 316 |
* @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int, int) |
| 317 |
*/ |
| 318 |
public void setObject( |
| 319 |
int parameterIndex, |
| 320 |
Object x, |
| 321 |
int targetSqlType, |
| 322 |
int scale) |
| 323 |
throws SQLException { |
| 324 |
st.setObject(parameterIndex,x,targetSqlType,scale); |
| 325 |
putParam(parameterIndex,x); |
| 326 |
} |
| 327 |
|
| 328 |
/* (non-Javadoc) |
| 329 |
* @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int) |
| 330 |
*/ |
| 331 |
public void setObject(int parameterIndex, Object x, int targetSqlType) |
| 332 |
throws SQLException { |
| 333 |
st.setObject(parameterIndex, x, targetSqlType); |
| 334 |
putParam(parameterIndex, x); |
| 335 |
} |
| 336 |
|
| 337 |
/* (non-Javadoc) |
| 338 |
* @see java.sql.PreparedStatement#setObject(int, java.lang.Object) |
| 339 |
*/ |
| 340 |
public void setObject(int parameterIndex, Object x) throws SQLException { |
| 341 |
st.setObject(parameterIndex, x); |
| 342 |
putParam(parameterIndex, x); |
| 343 |
} |
| 344 |
|
| 345 |
/* (non-Javadoc) |
| 346 |
* @see java.sql.PreparedStatement#setRef(int, java.sql.Ref) |
| 347 |
*/ |
| 348 |
public void setRef(int i, Ref x) throws SQLException { |
| 349 |
st.setRef(i, x); |
| 350 |
putParam(i, x); |
| 351 |
} |
| 352 |
|
| 353 |
/* (non-Javadoc) |
| 354 |
* @see java.sql.PreparedStatement#setShort(int, short) |
| 355 |
*/ |
| 356 |
public void setShort(int parameterIndex, short x) throws SQLException { |
| 357 |
st.setShort(parameterIndex, x); |
| 358 |
putParam(parameterIndex, new Short(x)); |
| 359 |
} |
| 360 |
|
| 361 |
/* (non-Javadoc) |
| 362 |
* @see java.sql.PreparedStatement#setString(int, java.lang.String) |
| 363 |
*/ |
| 364 |
public void setString(int parameterIndex, String x) throws SQLException { |
| 365 |
st.setString(parameterIndex, x); |
| 366 |
putParam(parameterIndex, x); |
| 367 |
} |
| 368 |
|
| 369 |
/* (non-Javadoc) |
| 370 |
* @see java.sql.PreparedStatement#setTime(int, java.sql.Time, java.util.Calendar) |
| 371 |
*/ |
| 372 |
public void setTime(int parameterIndex, Time x, Calendar cal) |
| 373 |
throws SQLException { |
| 374 |
st.setTime(parameterIndex, x, cal); |
| 375 |
putParam(parameterIndex, x); |
| 376 |
} |
| 377 |
|
| 378 |
/* (non-Javadoc) |
| 379 |
* @see java.sql.PreparedStatement#setTime(int, java.sql.Time) |
| 380 |
*/ |
| 381 |
public void setTime(int parameterIndex, Time x) throws SQLException { |
| 382 |
st.setTime(parameterIndex, x); |
| 383 |
putParam(parameterIndex, x); |
| 384 |
} |
| 385 |
|
| 386 |
/* (non-Javadoc) |
| 387 |
* @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp, java.util.Calendar) |
| 388 |
*/ |
| 389 |
public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) |
| 390 |
throws SQLException { |
| 391 |
st.setTimestamp(parameterIndex, x, cal); |
| 392 |
putParam(parameterIndex, x); |
| 393 |
} |
| 394 |
|
| 395 |
/* (non-Javadoc) |
| 396 |
* @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp) |
| 397 |
*/ |
| 398 |
public void setTimestamp(int parameterIndex, Timestamp x) |
| 399 |
throws SQLException { |
| 400 |
st.setTimestamp(parameterIndex, x); |
| 401 |
putParam(parameterIndex, x); |
| 402 |
} |
| 403 |
|
| 404 |
/** |
| 405 |
* @see java.sql.PreparedStatement#setUnicodeStream(int, java.io.InputStream, int) |
| 406 |
* @deprecated |
| 407 |
*/ |
| 408 |
public void setUnicodeStream(int parameterIndex, InputStream x, int length) |
| 409 |
throws SQLException { |
| 410 |
st.setUnicodeStream(parameterIndex, x, length); |
| 411 |
// AMS putParam(parameterIndex, x); |
| 412 |
} |
| 413 |
|
| 414 |
/* (non-Javadoc) |
| 415 |
* @see java.sql.PreparedStatement#setURL(int, java.net.URL) |
| 416 |
*/ |
| 417 |
public void setURL(int parameterIndex, URL x) throws SQLException { |
| 418 |
st.setURL(parameterIndex, x); |
| 419 |
putParam(parameterIndex, x); |
| 420 |
} |
| 421 |
|
| 422 |
/* (non-Javadoc) |
| 423 |
* @see java.sql.Statement#addBatch(java.lang.String) |
| 424 |
*/ |
| 425 |
public void addBatch(String sql) throws SQLException { |
| 426 |
st.addBatch(sql); |
| 427 |
batchSqlList.add(sql); |
| 428 |
} |
| 429 |
|
| 430 |
/* (non-Javadoc) |
| 431 |
* @see java.sql.Statement#cancel() |
| 432 |
*/ |
| 433 |
public void cancel() throws SQLException { |
| 434 |
st.cancel(); |
| 435 |
} |
| 436 |
|
| 437 |
/* (non-Javadoc) |
| 438 |
* @see java.sql.Statement#clearBatch() |
| 439 |
*/ |
| 440 |
public void clearBatch() throws SQLException { |
| 441 |
st.clearBatch(); |
| 442 |
batchSqlList.clear(); |
| 443 |
} |
| 444 |
|
| 445 |
/* (non-Javadoc) |
| 446 |
* @see java.sql.Statement#clearWarnings() |
| 447 |
*/ |
| 448 |
public void clearWarnings() throws SQLException { |
| 449 |
st.clearWarnings(); |
| 450 |
} |
| 451 |
|
| 452 |
/* (non-Javadoc) |
| 453 |
* @see java.sql.Statement#close() |
| 454 |
*/ |
| 455 |
public void close() throws SQLException { |
| 456 |
st.close(); |
| 457 |
} |
| 458 |
|
| 459 |
/* (non-Javadoc) |
| 460 |
* @see java.sql.Statement#execute(java.lang.String, int) |
| 461 |
*/ |
| 462 |
public boolean execute(String sql, int autoGeneratedKeys) |
| 463 |
throws SQLException { |
| 464 |
|
| 465 |
try { |
| 466 |
Survey s = new Survey(); |
| 467 |
boolean r = st.execute(sql, autoGeneratedKeys); |
| 468 |
Log.printlnSqlLog("executeQuery " + sql, s.doEnd(), paramMap); |
| 469 |
return r; |
| 470 |
} catch (SQLException e) { |
| 471 |
Log.printlnSqlExceptionLog("executeQuery " + sql, e); |
| 472 |
throw e; |
| 473 |
} |
| 474 |
|
| 475 |
// long s = System.currentTimeMillis(); |
| 476 |
// boolean r = st.execute(sql, autoGeneratedKeys); |
| 477 |
// Log.println("executeQuery " + sql, s, System.currentTimeMillis()); |
| 478 |
// return r; |
| 479 |
|
| 480 |
// Log.println("execute " + sql); |
| 481 |
// return st.execute(sql, autoGeneratedKeys); |
| 482 |
} |
| 483 |
|
| 484 |
/* (non-Javadoc) |
| 485 |
* @see java.sql.Statement#execute(java.lang.String, int[]) |
| 486 |
*/ |
| 487 |
public boolean execute(String sql, int[] columnIndexes) |
| 488 |
throws SQLException { |
| 489 |
|
| 490 |
try { |
| 491 |
Survey s = new Survey(); |
| 492 |
boolean r = st.execute(sql, columnIndexes); |
| 493 |
Log.printlnSqlLog("execute " + sql, s.doEnd(), paramMap); |
| 494 |
return r; |
| 495 |
} catch (SQLException e) { |
| 496 |
Log.printlnSqlExceptionLog("execute " + sql, e); |
| 497 |
throw e; |
| 498 |
} |
| 499 |
|
| 500 |
// Log.println("execute " + sql); |
| 501 |
// return st.execute(sql, columnIndexes); |
| 502 |
} |
| 503 |
|
| 504 |
/* (non-Javadoc) |
| 505 |
* @see java.sql.Statement#execute(java.lang.String, java.lang.String[]) |
| 506 |
*/ |
| 507 |
public boolean execute(String sql, String[] columnNames) |
| 508 |
throws SQLException { |
| 509 |
|
| 510 |
try { |
| 511 |
Survey s = new Survey(); |
| 512 |
boolean r = st.execute(sql, columnNames); |
| 513 |
Log.printlnSqlLog("execute " + sql, s.doEnd(), paramMap); |
| 514 |
return r; |
| 515 |
} catch (SQLException e) { |
| 516 |
Log.printlnSqlExceptionLog("execute " + sql, e); |
| 517 |
throw e; |
| 518 |
} |
| 519 |
|
| 520 |
// Log.println("execute " + sql); |
| 521 |
// return st.execute(sql, columnNames); |
| 522 |
} |
| 523 |
|
| 524 |
/* (non-Javadoc) |
| 525 |
* @see java.sql.Statement#execute(java.lang.String) |
| 526 |
*/ |
| 527 |
public boolean execute(String sql) throws SQLException { |
| 528 |
|
| 529 |
try { |
| 530 |
Survey s = new Survey(); |
| 531 |
boolean r = st.execute(sql); |
| 532 |
Log.printlnSqlLog("execute " + sql, s.doEnd(), paramMap); |
| 533 |
return r; |
| 534 |
} catch (SQLException e) { |
| 535 |
Log.printlnSqlExceptionLog("execute " + sql, e); |
| 536 |
throw e; |
| 537 |
} |
| 538 |
|
| 539 |
// Log.println("execute " + sql); |
| 540 |
// return st.execute(sql); |
| 541 |
} |
| 542 |
|
| 543 |
/* (non-Javadoc) |
| 544 |
* @see java.sql.Statement#executeBatch() |
| 545 |
*/ |
| 546 |
public int[] executeBatch() throws SQLException { |
| 547 |
|
| 548 |
try { |
| 549 |
Survey s = new Survey(); |
| 550 |
int[] c = st.executeBatch(); |
| 551 |
|
| 552 |
// 実行したSQLを全て出力 |
| 553 |
int i = 0; |
| 554 |
for(Iterator it = batchSqlList.iterator(); it.hasNext();i++) { |
| 555 |
Log.printlnSqlLog("executeBatch " + it.next() + ", result " + c[i], s.doEnd(), paramMap); |
| 556 |
} |
| 557 |
return c; |
| 558 |
|
| 559 |
} catch (SQLException e) { |
| 560 |
Log.printlnSqlExceptionLog("executeBatch ", e); |
| 561 |
throw e; |
| 562 |
} finally { |
| 563 |
batchSqlList.clear(); |
| 564 |
} |
| 565 |
} |
| 566 |
|
| 567 |
/* (non-Javadoc) |
| 568 |
* @see java.sql.Statement#executeQuery(java.lang.String) |
| 569 |
*/ |
| 570 |
public ResultSet executeQuery(String sql) throws SQLException { |
| 571 |
|
| 572 |
try { |
| 573 |
Survey s = new Survey(); |
| 574 |
ResultSet r = st.executeQuery(sql); |
| 575 |
Log.printlnSqlLog("executeQuery " + sql, s.doEnd(), paramMap); |
| 576 |
return r; |
| 577 |
} catch (SQLException e) { |
| 578 |
Log.printlnSqlExceptionLog("executeQuery " + sql, e); |
| 579 |
throw e; |
| 580 |
} |
| 581 |
|
| 582 |
// Log.println("executeQuery " + sql); |
| 583 |
// return st.executeQuery(sql); |
| 584 |
} |
| 585 |
|
| 586 |
/* (non-Javadoc) |
| 587 |
* @see java.sql.Statement#executeUpdate(java.lang.String, int) |
| 588 |
*/ |
| 589 |
public int executeUpdate(String sql, int autoGeneratedKeys) |
| 590 |
throws SQLException { |
| 591 |
|
| 592 |
try { |
| 593 |
Survey s = new Survey(); |
| 594 |
int r = st.executeUpdate(sql, autoGeneratedKeys); |
| 595 |
Log.printlnSqlLog("executeUpdate " + sql, s.doEnd(), paramMap); |
| 596 |
return r; |
| 597 |
} catch (SQLException e) { |
| 598 |
Log.printlnSqlExceptionLog("executeUpdate " + sql, e); |
| 599 |
throw e; |
| 600 |
} |
| 601 |
} |
| 602 |
|
| 603 |
/* (non-Javadoc) |
| 604 |
* @see java.sql.Statement#executeUpdate(java.lang.String, int[]) |
| 605 |
*/ |
| 606 |
public int executeUpdate(String sql, int[] columnIndexes) |
| 607 |
throws SQLException { |
| 608 |
|
| 609 |
try { |
| 610 |
Survey s = new Survey(); |
| 611 |
int r = st.executeUpdate(sql, columnIndexes); |
| 612 |
Log.printlnSqlLog("executeUpdate " + sql, s.doEnd(), paramMap); |
| 613 |
return r; |
| 614 |
} catch (SQLException e) { |
| 615 |
Log.printlnSqlExceptionLog("executeUpdate " + sql, e); |
| 616 |
throw e; |
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
/* (non-Javadoc) |
| 621 |
* @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[]) |
| 622 |
*/ |
| 623 |
public int executeUpdate(String sql, String[] columnNames) |
| 624 |
throws SQLException { |
| 625 |
|
| 626 |
try { |
| 627 |
Survey s = new Survey(); |
| 628 |
int r = st.executeUpdate(sql, columnNames); |
| 629 |
Log.printlnSqlLog("executeUpdate " + sql, s.doEnd(), paramMap); |
| 630 |
return r; |
| 631 |
} catch (SQLException e) { |
| 632 |
Log.printlnSqlExceptionLog("executeUpdate " + sql, e); |
| 633 |
throw e; |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
/* (non-Javadoc) |
| 638 |
* @see java.sql.Statement#executeUpdate(java.lang.String) |
| 639 |
*/ |
| 640 |
public int executeUpdate(String sql) throws SQLException { |
| 641 |
|
| 642 |
try { |
| 643 |
Survey s = new Survey(); |
| 644 |
int r = st.executeUpdate(sql); |
| 645 |
Log.printlnSqlLog("executeUpdate " + sql, s.doEnd(), paramMap); |
| 646 |
return r; |
| 647 |
} catch (SQLException e) { |
| 648 |
Log.printlnSqlExceptionLog("executeUpdate " + sql, e); |
| 649 |
throw e; |
| 650 |
} |
| 651 |
|
| 652 |
// Log.println("executeUpdate " + sql); |
| 653 |
// return st.executeUpdate(sql); |
| 654 |
} |
| 655 |
|
| 656 |
/* (non-Javadoc) |
| 657 |
* @see java.sql.Statement#getConnection() |
| 658 |
*/ |
| 659 |
public Connection getConnection() throws SQLException { |
| 660 |
return st.getConnection(); |
| 661 |
} |
| 662 |
|
| 663 |
/* (non-Javadoc) |
| 664 |
* @see java.sql.Statement#getFetchDirection() |
| 665 |
*/ |
| 666 |
public int getFetchDirection() throws SQLException { |
| 667 |
return st.getFetchDirection(); |
| 668 |
} |
| 669 |
|
| 670 |
/* (non-Javadoc) |
| 671 |
* @see java.sql.Statement#getFetchSize() |
| 672 |
*/ |
| 673 |
public int getFetchSize() throws SQLException { |
| 674 |
return st.getFetchSize(); |
| 675 |
} |
| 676 |
|
| 677 |
/* (non-Javadoc) |
| 678 |
* @see java.sql.Statement#getGeneratedKeys() |
| 679 |
*/ |
| 680 |
public ResultSet getGeneratedKeys() throws SQLException { |
| 681 |
return st.getGeneratedKeys(); |
| 682 |
} |
| 683 |
|
| 684 |
/* (non-Javadoc) |
| 685 |
* @see java.sql.Statement#getMaxFieldSize() |
| 686 |
*/ |
| 687 |
public int getMaxFieldSize() throws SQLException { |
| 688 |
return st.getMaxFieldSize(); |
| 689 |
} |
| 690 |
|
| 691 |
/* (non-Javadoc) |
| 692 |
* @see java.sql.Statement#getMaxRows() |
| 693 |
*/ |
| 694 |
public int getMaxRows() throws SQLException { |
| 695 |
return st.getMaxRows(); |
| 696 |
} |
| 697 |
|
| 698 |
/* (non-Javadoc) |
| 699 |
* @see java.sql.Statement#getMoreResults() |
| 700 |
*/ |
| 701 |
public boolean getMoreResults() throws SQLException { |
| 702 |
return st.getMoreResults(); |
| 703 |
} |
| 704 |
|
| 705 |
/* (non-Javadoc) |
| 706 |
* @see java.sql.Statement#getMoreResults(int) |
| 707 |
*/ |
| 708 |
public boolean getMoreResults(int current) throws SQLException { |
| 709 |
return st.getMoreResults(current); |
| 710 |
} |
| 711 |
|
| 712 |
/* (non-Javadoc) |
| 713 |
* @see java.sql.Statement#getQueryTimeout() |
| 714 |
*/ |
| 715 |
public int getQueryTimeout() throws SQLException { |
| 716 |
return st.getQueryTimeout(); |
| 717 |
} |
| 718 |
|
| 719 |
/* (non-Javadoc) |
| 720 |
* @see java.sql.Statement#getResultSet() |
| 721 |
*/ |
| 722 |
public ResultSet getResultSet() throws SQLException { |
| 723 |
return st.getResultSet(); |
| 724 |
} |
| 725 |
|
| 726 |
/* (non-Javadoc) |
| 727 |
* @see java.sql.Statement#getResultSetConcurrency() |
| 728 |
*/ |
| 729 |
public int getResultSetConcurrency() throws SQLException { |
| 730 |
return st.getResultSetConcurrency(); |
| 731 |
} |
| 732 |
|
| 733 |
/* (non-Javadoc) |
| 734 |
* @see java.sql.Statement#getResultSetHoldability() |
| 735 |
*/ |
| 736 |
public int getResultSetHoldability() throws SQLException { |
| 737 |
return st.getResultSetHoldability(); |
| 738 |
} |
| 739 |
|
| 740 |
/* (non-Javadoc) |
| 741 |
* @see java.sql.Statement#getResultSetType() |
| 742 |
*/ |
| 743 |
public int getResultSetType() throws SQLException { |
| 744 |
return st.getResultSetType(); |
| 745 |
} |
| 746 |
|
| 747 |
/* (non-Javadoc) |
| 748 |
* @see java.sql.Statement#getUpdateCount() |
| 749 |
*/ |
| 750 |
public int getUpdateCount() throws SQLException { |
| 751 |
return st.getUpdateCount(); |
| 752 |
} |
| 753 |
|
| 754 |
/* (non-Javadoc) |
| 755 |
* @see java.sql.Statement#getWarnings() |
| 756 |
*/ |
| 757 |
public SQLWarning getWarnings() throws SQLException { |
| 758 |
return st.getWarnings(); |
| 759 |
} |
| 760 |
|
| 761 |
/* (non-Javadoc) |
| 762 |
* @see java.sql.Statement#setCursorName(java.lang.String) |
| 763 |
*/ |
| 764 |
public void setCursorName(String name) throws SQLException { |
| 765 |
st.setCursorName(name); |
| 766 |
} |
| 767 |
|
| 768 |
/* (non-Javadoc) |
| 769 |
* @see java.sql.Statement#setEscapeProcessing(boolean) |
| 770 |
*/ |
| 771 |
public void setEscapeProcessing(boolean enable) throws SQLException { |
| 772 |
st.setEscapeProcessing(enable); |
| 773 |
} |
| 774 |
|
| 775 |
/* (non-Javadoc) |
| 776 |
* @see java.sql.Statement#setFetchDirection(int) |
| 777 |
*/ |
| 778 |
public void setFetchDirection(int direction) throws SQLException { |
| 779 |
st.setFetchDirection(direction); |
| 780 |
} |
| 781 |
|
| 782 |
/* (non-Javadoc) |
| 783 |
* @see java.sql.Statement#setFetchSize(int) |
| 784 |
*/ |
| 785 |
public void setFetchSize(int rows) throws SQLException { |
| 786 |
st.setFetchSize(rows); |
| 787 |
} |
| 788 |
|
| 789 |
/* (non-Javadoc) |
| 790 |
* @see java.sql.Statement#setMaxFieldSize(int) |
| 791 |
*/ |
| 792 |
public void setMaxFieldSize(int max) throws SQLException { |
| 793 |
st.setMaxFieldSize(max); |
| 794 |
} |
| 795 |
|
| 796 |
/* (non-Javadoc) |
| 797 |
* @see java.sql.Statement#setMaxRows(int) |
| 798 |
*/ |
| 799 |
public void setMaxRows(int max) throws SQLException { |
| 800 |
st.setMaxRows(max); |
| 801 |
} |
| 802 |
|
| 803 |
/* (non-Javadoc) |
| 804 |
* @see java.sql.Statement#setQueryTimeout(int) |
| 805 |
*/ |
| 806 |
public void setQueryTimeout(int seconds) throws SQLException { |
| 807 |
st.setQueryTimeout(seconds); |
| 808 |
} |
| 809 |
|
| 810 |
/** |
| 811 |
* paramPut<BR> |
| 812 |
* パラメーターマップに値を格納 |
| 813 |
* @param parameterIndex パラメータインデックス(1.2..) |
| 814 |
* @param object 値 |
| 815 |
*/ |
| 816 |
private void putParam(int parameterIndex, Object object) { |
| 817 |
|
| 818 |
paramPut(Integer.toString(parameterIndex), object); |
| 819 |
|
| 820 |
} |
| 821 |
|
| 822 |
/** |
| 823 |
* paramPut<BR> |
| 824 |
* パラメーターマップに値を格納 |
| 825 |
* @param parameterIndex パラメータインデックス("1"."2"..) |
| 826 |
* @param object 値 |
| 827 |
*/ |
| 828 |
private void paramPut(String parameterIndex, Object object) { |
| 829 |
|
| 830 |
paramMap.put(parameterIndex, object); |
| 831 |
|
| 832 |
} |
| 833 |
|
| 834 |
/** |
| 835 |
* @return |
| 836 |
* @throws SQLException |
| 837 |
* @see java.sql.Statement#isClosed() |
| 838 |
*/ |
| 839 |
public boolean isClosed() throws SQLException { |
| 840 |
return st.isClosed(); |
| 841 |
} |
| 842 |
|
| 843 |
/** |
| 844 |
* @return |
| 845 |
* @throws SQLException |
| 846 |
* @see java.sql.Statement#isPoolable() |
| 847 |
*/ |
| 848 |
public boolean isPoolable() throws SQLException { |
| 849 |
return st.isPoolable(); |
| 850 |
} |
| 851 |
|
| 852 |
/** |
| 853 |
* @param iface |
| 854 |
* @return |
| 855 |
* @throws SQLException |
| 856 |
* @see java.sql.Wrapper#isWrapperFor(java.lang.Class) |
| 857 |
*/ |
| 858 |
public boolean isWrapperFor(Class<?> iface) throws SQLException { |
| 859 |
return st.isWrapperFor(iface); |
| 860 |
} |
| 861 |
|
| 862 |
/** |
| 863 |
* @param parameterIndex |
| 864 |
* @param x |
| 865 |
* @param length |
| 866 |
* @throws SQLException |
| 867 |
* @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream, long) |
| 868 |
*/ |
| 869 |
public void setAsciiStream(int parameterIndex, InputStream x, long length) |
| 870 |
throws SQLException { |
| 871 |
st.setAsciiStream(parameterIndex, x, length); |
| 872 |
} |
| 873 |
|
| 874 |
/** |
| 875 |
* @param parameterIndex |
| 876 |
* @param x |
| 877 |
* @throws SQLException |
| 878 |
* @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream) |
| 879 |
*/ |
| 880 |
public void setAsciiStream(int parameterIndex, InputStream x) |
| 881 |
throws SQLException { |
| 882 |
st.setAsciiStream(parameterIndex, x); |
| 883 |
} |
| 884 |
|
| 885 |
/** |
| 886 |
* @param parameterIndex |
| 887 |
* @param x |
| 888 |
* @param length |
| 889 |
* @throws SQLException |
| 890 |
* @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, long) |
| 891 |
*/ |
| 892 |
public void setBinaryStream(int parameterIndex, InputStream x, long length) |
| 893 |
throws SQLException { |
| 894 |
st.setBinaryStream(parameterIndex, x, length); |
| 895 |
} |
| 896 |
|
| 897 |
/** |
| 898 |
* @param parameterIndex |
| 899 |
* @param x |
| 900 |
* @throws SQLException |
| 901 |
* @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream) |
| 902 |
*/ |
| 903 |
public void setBinaryStream(int parameterIndex, InputStream x) |
| 904 |
throws SQLException { |
| 905 |
st.setBinaryStream(parameterIndex, x); |
| 906 |
} |
| 907 |
|
| 908 |
/** |
| 909 |
* @param parameterIndex |
| 910 |
* @param inputStream |
| 911 |
* @param length |
| 912 |
* @throws SQLException |
| 913 |
* @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream, long) |
| 914 |
*/ |
| 915 |
public void setBlob(int parameterIndex, InputStream inputStream, long length) |
| 916 |
throws SQLException { |
| 917 |
st.setBlob(parameterIndex, inputStream, length); |
| 918 |
} |
| 919 |
|
| 920 |
/** |
| 921 |
* @param parameterIndex |
| 922 |
* @param inputStream |
| 923 |
* @throws SQLException |
| 924 |
* @see java.sql.PreparedStatement#setBlob(int, java.io.InputStream) |
| 925 |
*/ |
| 926 |
public void setBlob(int parameterIndex, InputStream inputStream) |
| 927 |
throws SQLException { |
| 928 |
st.setBlob(parameterIndex, inputStream); |
| 929 |
} |
| 930 |
|
| 931 |
/** |
| 932 |
* @param parameterIndex |
| 933 |
* @param reader |
| 934 |
* @param length |
| 935 |
* @throws SQLException |
| 936 |
* @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, long) |
| 937 |
*/ |
| 938 |
public void setCharacterStream(int parameterIndex, Reader reader, long length) |
| 939 |
throws SQLException { |
| 940 |
st.setCharacterStream(parameterIndex, reader, length); |
| 941 |
} |
| 942 |
|
| 943 |
/** |
| 944 |
* @param parameterIndex |
| 945 |
* @param reader |
| 946 |
* @throws SQLException |
| 947 |
* @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader) |
| 948 |
*/ |
| 949 |
public void setCharacterStream(int parameterIndex, Reader reader) |
| 950 |
throws SQLException { |
| 951 |
st.setCharacterStream(parameterIndex, reader); |
| 952 |
} |
| 953 |
|
| 954 |
/** |
| 955 |
* @param parameterIndex |
| 956 |
* @param reader |
| 957 |
* @param length |
| 958 |
* @throws SQLException |
| 959 |
* @see java.sql.PreparedStatement#setClob(int, java.io.Reader, long) |
| 960 |
*/ |
| 961 |
public void setClob(int parameterIndex, Reader reader, long length) |
| 962 |
throws SQLException { |
| 963 |
st.setClob(parameterIndex, reader, length); |
| 964 |
} |
| 965 |
|
| 966 |
/** |
| 967 |
* @param parameterIndex |
| 968 |
* @param reader |
| 969 |
* @throws SQLException |
| 970 |
* @see java.sql.PreparedStatement#setClob(int, java.io.Reader) |
| 971 |
*/ |
| 972 |
public void setClob(int parameterIndex, Reader reader) throws SQLException { |
| 973 |
st.setClob(parameterIndex, reader); |
| 974 |
} |
| 975 |
|
| 976 |
/** |
| 977 |
* @param parameterIndex |
| 978 |
* @param value |
| 979 |
* @param length |
| 980 |
* @throws SQLException |
| 981 |
* @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long) |
| 982 |
*/ |
| 983 |
public void setNCharacterStream(int parameterIndex, Reader value, long length) |
| 984 |
throws SQLException { |
| 985 |
st.setNCharacterStream(parameterIndex, value, length); |
| 986 |
} |
| 987 |
|
| 988 |
/** |
| 989 |
* @param parameterIndex |
| 990 |
* @param value |
| 991 |
* @throws SQLException |
| 992 |
* @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader) |
| 993 |
*/ |
| 994 |
public void setNCharacterStream(int parameterIndex, Reader value) |
| 995 |
throws SQLException { |
| 996 |
st.setNCharacterStream(parameterIndex, value); |
| 997 |
} |
| 998 |
|
| 999 |
/** |
| 1000 |
* @param parameterIndex |
| 1001 |
* @param value |
| 1002 |
* @throws SQLException |
| 1003 |
* @see java.sql.PreparedStatement#setNClob(int, java.sql.NClob) |
| 1004 |
*/ |
| 1005 |
public void setNClob(int parameterIndex, NClob value) throws SQLException { |
| 1006 |
st.setNClob(parameterIndex, value); |
| 1007 |
} |
| 1008 |
|
| 1009 |
/** |
| 1010 |
* @param parameterIndex |
| 1011 |
* @param reader |
| 1012 |
* @param length |
| 1013 |
* @throws SQLException |
| 1014 |
* @see java.sql.PreparedStatement#setNClob(int, java.io.Reader, long) |
| 1015 |
*/ |
| 1016 |
public void setNClob(int parameterIndex, Reader reader, long length) |
| 1017 |
throws SQLException { |
| 1018 |
st.setNClob(parameterIndex, reader, length); |
| 1019 |
} |
| 1020 |
|
| 1021 |
/** |
| 1022 |
* @param parameterIndex |
| 1023 |
* @param reader |
| 1024 |
* @throws SQLException |
| 1025 |
* @see java.sql.PreparedStatement#setNClob(int, java.io.Reader) |
| 1026 |
*/ |
| 1027 |
public void setNClob(int parameterIndex, Reader reader) throws SQLException { |
| 1028 |
st.setNClob(parameterIndex, reader); |
| 1029 |
} |
| 1030 |
|
| 1031 |
/** |
| 1032 |
* @param parameterIndex |
| 1033 |
* @param value |
| 1034 |
* @throws SQLException |
| 1035 |
* @see java.sql.PreparedStatement#setNString(int, java.lang.String) |
| 1036 |
*/ |
| 1037 |
public void setNString(int parameterIndex, String value) throws SQLException { |
| 1038 |
st.setNString(parameterIndex, value); |
| 1039 |
} |
| 1040 |
|
| 1041 |
/** |
| 1042 |
* @param poolable |
| 1043 |
* @throws SQLException |
| 1044 |
* @see java.sql.Statement#setPoolable(boolean) |
| 1045 |
*/ |
| 1046 |
public void setPoolable(boolean poolable) throws SQLException { |
| 1047 |
st.setPoolable(poolable); |
| 1048 |
} |
| 1049 |
|
| 1050 |
/** |
| 1051 |
* @param parameterIndex |
| 1052 |
* @param x |
| 1053 |
* @throws SQLException |
| 1054 |
* @see java.sql.PreparedStatement#setRowId(int, java.sql.RowId) |
| 1055 |
*/ |
| 1056 |
public void setRowId(int parameterIndex, RowId x) throws SQLException { |
| 1057 |
st.setRowId(parameterIndex, x); |
| 1058 |
} |
| 1059 |
|
| 1060 |
/** |
| 1061 |
* @param parameterIndex |
| 1062 |
* @param xmlObject |
| 1063 |
* @throws SQLException |
| 1064 |
* @see java.sql.PreparedStatement#setSQLXML(int, java.sql.SQLXML) |
| 1065 |
*/ |
| 1066 |
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { |
| 1067 |
st.setSQLXML(parameterIndex, xmlObject); |
| 1068 |
} |
| 1069 |
|
| 1070 |
/** |
| 1071 |
* @param <T> |
| 1072 |
* @param iface |
| 1073 |
* @return |
| 1074 |
* @throws SQLException |
| 1075 |
* @see java.sql.Wrapper#unwrap(java.lang.Class) |
| 1076 |
*/ |
| 1077 |
public <T> T unwrap(Class<T> iface) throws SQLException { |
| 1078 |
return st.unwrap(iface); |
| 1079 |
} |
| 1080 |
|
| 1081 |
} |