1 22 package org.enhydra.jdbc.core; 23 24 import org.enhydra.jdbc.util.Logger; 25 import org.enhydra.jdbc.util.JdbcUtil; 26 27 import java.io.InputStream ; 28 import java.io.Reader ; 29 import java.math.BigDecimal ; 30 import java.sql.Array ; 31 import java.sql.Blob ; 32 import java.sql.Clob ; 33 import java.sql.Connection ; 34 import java.sql.Date ; 35 import java.sql.PreparedStatement ; 36 import java.sql.Ref ; 37 import java.sql.ResultSet ; 38 import java.sql.ResultSetMetaData ; 39 import java.sql.SQLException ; 40 import java.sql.SQLWarning ; 41 import java.sql.Time ; 42 import java.sql.Timestamp ; 43 import java.util.Calendar ; 44 45 50 public abstract class CorePreparedStatement 51 extends JdbcUtil 52 implements PreparedStatement { 53 54 public PreparedStatement ps; 55 57 public void setLogger(Logger alog) { 58 log = alog; 59 } 60 61 public void addBatch() throws SQLException { 62 try { 64 ps.addBatch(); 65 } catch (SQLException e) { 66 catchInvoke(e); 67 } 68 } 69 70 public void clearParameters() throws SQLException { 71 try { 73 ps.clearParameters(); 74 } catch (SQLException e) { 75 catchInvoke(e); 76 } 77 } 78 79 public boolean execute() throws SQLException { 80 try { 82 return ps.execute(); 83 } catch (SQLException e) { 84 catchInvoke(e); 85 } 86 return false; 87 } 88 89 public ResultSet executeQuery() throws SQLException { 90 try { 92 return ps.executeQuery(); 93 } catch (SQLException e) { 94 catchInvoke(e); 95 } 96 return null; 97 } 98 99 public int executeUpdate() throws SQLException { 100 try { 102 return ps.executeUpdate(); 103 } catch (SQLException e) { 104 catchInvoke(e); 105 } 106 return 0; 107 } 108 109 public ResultSetMetaData getMetaData() throws SQLException { 110 try { 112 return ps.getMetaData(); 113 } catch (SQLException e) { 114 catchInvoke(e); 115 } 116 return null; 117 } 118 119 public void setArray(int i, Array x) throws SQLException { 120 try { 122 ps.setArray(i, x); 123 } catch (SQLException e) { 124 catchInvoke(e); 125 } 126 } 127 128 public void setAsciiStream(int parameterIndex, InputStream x, int length) 129 throws SQLException { 130 try { 132 ps.setAsciiStream(parameterIndex, x, length); 133 } catch (SQLException e) { 134 catchInvoke(e); 135 } 136 } 137 138 public void setBigDecimal(int parameterIndex, BigDecimal x) 139 throws SQLException { 140 try { 142 ps.setBigDecimal(parameterIndex, x); 143 } catch (SQLException e) { 144 catchInvoke(e); 145 } 146 } 147 148 public void setBinaryStream(int parameterIndex, InputStream x, int length) 149 throws SQLException { 150 try { 152 ps.setBinaryStream(parameterIndex, x, length); 153 } catch (SQLException e) { 154 catchInvoke(e); 155 } 156 } 157 158 public void setBlob(int i, Blob x) throws SQLException { 159 try { 161 ps.setBlob(i, x); 162 } catch (SQLException e) { 163 catchInvoke(e); 164 } 165 } 166 167 public void setBoolean(int parameterIndex, boolean x) throws SQLException { 168 try { 170 ps.setBoolean(parameterIndex, x); 171 } catch (SQLException e) { 172 catchInvoke(e); 173 } 174 } 175 176 public void setByte(int parameterIndex, byte x) throws SQLException { 177 try { 179 ps.setByte(parameterIndex, x); 180 } catch (SQLException e) { 181 catchInvoke(e); 182 } 183 } 184 185 public void setBytes(int parameterIndex, byte x[]) throws SQLException { 186 try { 188 ps.setBytes(parameterIndex, x); 189 } catch (SQLException e) { 190 catchInvoke(e); 191 } 192 } 193 194 public void setCharacterStream( 195 int parameterIndex, 196 Reader reader, 197 int length) 198 throws SQLException { 199 try { 201 ps.setCharacterStream(parameterIndex, reader, length); 202 } catch (SQLException e) { 203 catchInvoke(e); 204 } 205 } 206 207 public void setClob(int i, Clob x) throws SQLException { 208 try { 210 ps.setClob(i, x); 211 } catch (SQLException e) { 212 catchInvoke(e); 213 } 214 } 215 216 public void setDate(int parameterIndex, Date x) throws SQLException { 217 try { 219 ps.setDate(parameterIndex, x); 220 } catch (SQLException e) { 221 catchInvoke(e); 222 } 223 } 224 225 public void setDate(int parameterIndex, Date x, Calendar cal) 226 throws SQLException { 227 try { 229 ps.setDate(parameterIndex, x, cal); 230 } catch (SQLException e) { 231 catchInvoke(e); 232 } 233 } 234 235 public void setDouble(int parameterIndex, double x) throws SQLException { 236 try { 238 ps.setDouble(parameterIndex, x); 239 } catch (SQLException e) { 240 catchInvoke(e); 241 } 242 } 243 244 public void setFloat(int parameterIndex, float x) throws SQLException { 245 try { 247 ps.setFloat(parameterIndex, x); 248 } catch (SQLException e) { 249 catchInvoke(e); 250 } 251 } 252 253 public void setInt(int parameterIndex, int x) throws SQLException { 254 try { 256 ps.setInt(parameterIndex, x); 257 } catch (SQLException e) { 258 catchInvoke(e); 259 } 260 } 261 262 public void setLong(int parameterIndex, long x) throws SQLException { 263 try { 265 ps.setLong(parameterIndex, x); 266 } catch (SQLException e) { 267 catchInvoke(e); 268 } 269 } 270 271 public void setNull(int parameterIndex, int sqlType) throws SQLException { 272 try { 274 ps.setNull(parameterIndex, sqlType); 275 } catch (SQLException e) { 276 catchInvoke(e); 277 } 278 } 279 280 public void setNull(int paramIndex, int sqlType, String typeName) 281 throws SQLException { 282 try { 284 ps.setNull(paramIndex, sqlType, typeName); 285 } catch (SQLException e) { 286 catchInvoke(e); 287 } 288 } 289 290 public void setObject(int parameterIndex, Object x) throws SQLException { 291 try { 293 ps.setObject(parameterIndex, x); 294 } catch (SQLException e) { 295 catchInvoke(e); 296 } 297 } 298 299 public void setObject(int parameterIndex, Object x, int targetSqlType) 300 throws SQLException { 301 try { 303 ps.setObject(parameterIndex, x, targetSqlType); 304 } catch (SQLException e) { 305 catchInvoke(e); 306 } 307 } 308 309 public void setObject( 310 int parameterIndex, 311 Object x, 312 int targetSqlType, 313 int scale) 314 throws SQLException { 315 try { 317 ps.setObject(parameterIndex, x, targetSqlType, scale); 318 } catch (SQLException e) { 319 catchInvoke(e); 320 } 321 } 322 323 public void setRef(int i, Ref x) throws SQLException { 324 try { 326 ps.setRef(i, x); 327 } catch (SQLException e) { 328 catchInvoke(e); 329 } 330 } 331 332 public void setShort(int parameterIndex, short x) throws SQLException { 333 try { 335 ps.setShort(parameterIndex, x); 336 } catch (SQLException e) { 337 catchInvoke(e); 338 } 339 } 340 341 public void setString(int parameterIndex, String x) throws SQLException { 342 try { 344 ps.setString(parameterIndex, x); 345 } catch (SQLException e) { 346 catchInvoke(e); 347 } 348 } 349 350 public void setTime(int parameterIndex, Time x) throws SQLException { 351 try { 353 ps.setTime(parameterIndex, x); 354 } catch (SQLException e) { 355 catchInvoke(e); 356 } 357 } 358 359 public void setTime(int parameterIndex, Time x, Calendar cal) 360 throws SQLException { 361 try { 363 ps.setTime(parameterIndex, x, cal); 364 } catch (SQLException e) { 365 catchInvoke(e); 366 } 367 } 368 369 public void setTimestamp(int parameterIndex, Timestamp x) 370 throws SQLException { 371 try { 373 ps.setTimestamp(parameterIndex, x); 374 } catch (SQLException e) { 375 catchInvoke(e); 376 } 377 } 378 379 public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) 380 throws SQLException { 381 try { 383 ps.setTimestamp(parameterIndex, x, cal); 384 } catch (SQLException e) { 385 catchInvoke(e); 386 } 387 } 388 389 public void setUnicodeStream(int parameterIndex, InputStream x, int length) 390 throws SQLException { 391 try { 393 ps.setUnicodeStream(parameterIndex, x, length); 394 } catch (SQLException e) { 395 catchInvoke(e); 396 } 397 } 398 399 401 public void close() throws SQLException { 402 if (ps != null) { 403 ps.close(); 404 } 405 } 406 407 public int[] executeBatch() throws SQLException { 408 try { 410 return ps.executeBatch(); 411 } catch (SQLException e) { 412 catchInvoke(e); 413 } 414 return null; 415 } 416 417 public int getMaxFieldSize() throws SQLException { 418 try { 420 return ps.getMaxFieldSize(); 421 } catch (SQLException e) { 422 catchInvoke(e); 423 } 424 return 0; 425 } 426 427 public void setMaxFieldSize(int max) throws SQLException { 428 try { 430 ps.setMaxFieldSize(max); 431 } catch (SQLException e) { 432 catchInvoke(e); 433 } 434 } 435 436 public int getMaxRows() throws SQLException { 437 try { 439 return ps.getMaxRows(); 440 } catch (SQLException e) { 441 catchInvoke(e); 442 } 443 return 0; 444 } 445 446 public void setMaxRows(int max) throws SQLException { 447 try { 449 ps.setMaxRows(max); 450 } catch (SQLException e) { 451 catchInvoke(e); 452 } 453 } 454 455 public void setEscapeProcessing(boolean enable) throws SQLException { 456 try { 458 ps.setEscapeProcessing(enable); 459 } catch (SQLException e) { 460 catchInvoke(e); 461 } 462 } 463 464 public int getQueryTimeout() throws SQLException { 465 try { 467 return ps.getQueryTimeout(); 468 } catch (SQLException e) { 469 catchInvoke(e); 470 } 471 return 0; 472 } 473 474 public void setQueryTimeout(int seconds) throws SQLException { 475 try { 477 ps.setQueryTimeout(seconds); 478 } catch (SQLException e) { 479 catchInvoke(e); 480 } 481 } 482 483 public void cancel() throws SQLException { 484 try { 486 ps.cancel(); 487 } catch (SQLException e) { 488 catchInvoke(e); 489 } 490 } 491 492 public SQLWarning getWarnings() throws SQLException { 493 try { 495 return ps.getWarnings(); 496 } catch (SQLException e) { 497 catchInvoke(e); 498 } 499 return null; 500 } 501 502 public void clearWarnings() throws SQLException { 503 try { 505 ps.clearWarnings(); 506 } catch (SQLException e) { 507 catchInvoke(e); 508 } 509 } 510 511 public void setCursorName(String name) throws SQLException { 512 try { 514 ps.setCursorName(name); 515 } catch (SQLException e) { 516 catchInvoke(e); 517 } 518 } 519 520 public ResultSet getResultSet() throws SQLException { 521 try { 523 return ps.getResultSet(); 524 } catch (SQLException e) { 525 catchInvoke(e); 526 } 527 return null; 528 } 529 530 public int getUpdateCount() throws SQLException { 531 try { 533 return ps.getUpdateCount(); 534 } catch (SQLException e) { 535 catchInvoke(e); 536 } 537 return 0; 538 } 539 540 public boolean getMoreResults() throws SQLException { 541 try { 543 return ps.getMoreResults(); 544 } catch (SQLException e) { 545 catchInvoke(e); 546 } 547 return false; 548 } 549 550 public void setFetchDirection(int direction) throws SQLException { 551 try { 553 ps.setFetchDirection(direction); 554 } catch (SQLException e) { 555 catchInvoke(e); 556 } 557 } 558 559 public int getFetchDirection() throws SQLException { 560 try { 562 return ps.getFetchDirection(); 563 } catch (SQLException e) { 564 catchInvoke(e); 565 } 566 return 0; 567 } 568 569 public void setFetchSize(int rows) throws SQLException { 570 try { 572 ps.setFetchSize(rows); 573 } catch (SQLException e) { 574 catchInvoke(e); 575 } 576 } 577 578 public int getFetchSize() throws SQLException { 579 try { 581 return ps.getFetchSize(); 582 } catch (SQLException e) { 583 catchInvoke(e); 584 } 585 return 0; 586 } 587 588 public int getResultSetConcurrency() throws SQLException { 589 try { 591 return ps.getResultSetConcurrency(); 592 } catch (SQLException e) { 593 catchInvoke(e); 594 } 595 return 0; 596 } 597 598 public int getResultSetType() throws SQLException { 599 try { 601 return ps.getResultSetType(); 602 } catch (SQLException e) { 603 catchInvoke(e); 604 } 605 return 0; 606 } 607 608 public Connection getConnection() throws SQLException { 609 try { 611 return ps.getConnection(); 612 } catch (SQLException e) { 613 catchInvoke(e); 614 } 615 return null; 616 } 617 618 public void clearBatch() throws SQLException { 619 try { 621 ps.clearBatch(); 622 } catch (SQLException e) { 623 catchInvoke(e); 624 } 625 } 626 627 public void addBatch(String s) throws SQLException { 628 try { 630 ps.addBatch(s); 631 } catch (SQLException e) { 632 catchInvoke(e); 633 } 634 } 635 636 public boolean execute(String s) throws SQLException { 637 try { 639 return ps.execute(s); 640 } catch (SQLException e) { 641 catchInvoke(e); 642 } 643 return false; 644 } 645 646 public ResultSet executeQuery(String s) throws SQLException { 647 try { 649 return ps.executeQuery(s); 650 } catch (SQLException e) { 651 catchInvoke(e); 652 } 653 return null; 654 } 655 656 public int executeUpdate(String s) throws SQLException { 657 try { 659 return ps.executeUpdate(s); 660 } catch (SQLException e) { 661 catchInvoke(e); 662 } 663 return 0; 664 } 665 666 671 public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { 673 try { 674 return ps.execute(sql, autoGeneratedKeys); 675 } catch (SQLException e) { 676 catchInvoke(e); 677 } 678 return false; 679 } 680 public boolean execute(String sql, int[] columnIndexes) throws SQLException { 681 try { 682 return ps.execute(sql, columnIndexes); 683 } catch (SQLException e) { 684 catchInvoke(e); 685 } 686 return false; 687 } 688 public boolean execute(String sql, String [] columnNames) throws SQLException { 689 try { 690 return ps.execute(sql, columnNames); 691 } catch (SQLException e) { 692 catchInvoke(e); 693 } 694 return false; 695 } 696 public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { 697 try { 698 return ps.executeUpdate(sql, autoGeneratedKeys); 699 } catch (SQLException e) { 700 catchInvoke(e); 701 } 702 return 0; 703 } 704 public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { 705 try { 706 return ps.executeUpdate(sql, columnIndexes); 707 } catch (SQLException e) { 708 catchInvoke(e); 709 } 710 return 0; 711 } 712 public int executeUpdate(String sql, String [] columnNames) throws SQLException { 713 try { 714 return ps.executeUpdate(sql, columnNames); 715 } catch (SQLException e) { 716 catchInvoke(e); 717 } 718 return 0; 719 } 720 public java.sql.ResultSet getGeneratedKeys() throws SQLException { 721 try { 722 return ps.getGeneratedKeys(); 723 } catch (SQLException e) { 724 catchInvoke(e); 725 } 726 return null; 727 } 728 public boolean getMoreResults(int current) throws SQLException { 729 try { 730 return ps.getMoreResults(current); 731 } catch (SQLException e) { 732 catchInvoke(e); 733 } 734 return false; 735 } 736 public int getResultSetHoldability() throws SQLException { 737 try { 738 return ps.getResultSetHoldability(); 739 } catch (SQLException e) { 740 catchInvoke(e); 741 } 742 return 0; 743 } 744 public java.sql.ParameterMetaData getParameterMetaData() throws SQLException { 746 try { 747 return ps.getParameterMetaData(); 748 } catch (SQLException e) { 749 catchInvoke(e); 750 } 751 return null; 752 } 753 public void setURL(int parameterIndex, java.net.URL x) throws SQLException { 754 try { 755 ps.setURL(parameterIndex, x); 756 } catch (SQLException e) { 757 catchInvoke(e); 758 } 759 } 760 761 765 abstract public void preInvoke() throws SQLException ; 766 abstract public void catchInvoke(SQLException e) throws SQLException ; 767 768 } | Popular Tags |