1 2 9 10 package org.objectweb.rmijdbc; 11 12 import java.sql.*; 13 import java.rmi.RemoteException ; 14 15 import java.io.*; 16 17 22 38 39 public class RJPreparedStatement extends RJStatement 40 implements java.sql.PreparedStatement , java.io.Serializable { 41 42 RJPreparedStatementInterface rmiPrepStmt_; 43 44 public RJPreparedStatement(RJPreparedStatementInterface p, Connection c) { 45 super(p, c); 46 rmiPrepStmt_ = p; 47 } 48 49 55 public java.sql.ResultSet executeQuery() throws SQLException { 56 try { 57 return new RJResultSet(rmiPrepStmt_.executeQuery(), this); 58 } catch(RemoteException e) { 59 throw new java.sql.SQLException (e.getMessage()); 60 } 61 } 62 63 71 public int executeUpdate() throws SQLException { 72 try { 73 return rmiPrepStmt_.executeUpdate(); 74 } catch(RemoteException e) { 75 throw new java.sql.SQLException (e.getMessage()); 76 } 77 } 78 79 87 public void setNull(int parameterIndex, int sqlType) throws SQLException { 88 try { 89 rmiPrepStmt_.setNull(parameterIndex, sqlType); 90 } catch(RemoteException e) { 91 throw new java.sql.SQLException (e.getMessage()); 92 } 93 } 94 95 102 public void setBoolean(int parameterIndex, boolean x) throws SQLException { 103 try { 104 rmiPrepStmt_.setBoolean(parameterIndex, x); 105 } catch(RemoteException e) { 106 throw new java.sql.SQLException (e.getMessage()); 107 } 108 } 109 110 117 public void setByte(int parameterIndex, byte x) throws SQLException { 118 try { 119 rmiPrepStmt_.setByte(parameterIndex, x); 120 } catch(RemoteException e) { 121 throw new java.sql.SQLException (e.getMessage()); 122 } 123 } 124 125 132 public void setShort(int parameterIndex, short x) throws SQLException { 133 try { 134 rmiPrepStmt_.setShort(parameterIndex, x); 135 } catch(RemoteException e) { 136 throw new java.sql.SQLException (e.getMessage()); 137 } 138 } 139 140 147 public void setInt(int parameterIndex, int x) throws SQLException { 148 try { 149 rmiPrepStmt_.setInt(parameterIndex, x); 150 } catch(RemoteException e) { 151 throw new java.sql.SQLException (e.getMessage()); 152 } 153 } 154 155 162 public void setLong(int parameterIndex, long x) throws SQLException { 163 try { 164 rmiPrepStmt_.setLong(parameterIndex, x); 165 } catch(RemoteException e) { 166 throw new java.sql.SQLException (e.getMessage()); 167 } 168 } 169 170 177 public void setFloat(int parameterIndex, float x) throws SQLException { 178 try { 179 rmiPrepStmt_.setFloat(parameterIndex, x); 180 } catch(RemoteException e) { 181 throw new java.sql.SQLException (e.getMessage()); 182 } 183 } 184 185 192 public void setDouble(int parameterIndex, double x) throws SQLException { 193 try { 194 rmiPrepStmt_.setDouble(parameterIndex, x); 195 } catch(RemoteException e) { 196 throw new java.sql.SQLException (e.getMessage()); 197 } 198 } 199 200 207 public void setBigDecimal(int parameterIndex, java.math.BigDecimal x) 208 throws SQLException { 209 try { 210 rmiPrepStmt_.setBigDecimal(parameterIndex, x); 211 } catch(RemoteException e) { 212 throw new java.sql.SQLException (e.getMessage()); 213 } 214 } 215 216 225 public void setString(int parameterIndex, String x) throws SQLException { 226 try { 227 rmiPrepStmt_.setString(parameterIndex, x); 228 } catch(RemoteException e) { 229 throw new java.sql.SQLException (e.getMessage()); 230 } 231 } 232 233 242 public void setBytes(int parameterIndex, byte x[]) throws SQLException { 243 try { 244 rmiPrepStmt_.setBytes(parameterIndex, x); 245 } catch(RemoteException e) { 246 throw new java.sql.SQLException (e.getMessage()); 247 } 248 } 249 250 257 public void setDate(int parameterIndex, java.sql.Date x) 258 throws SQLException { 259 try { 260 rmiPrepStmt_.setDate(parameterIndex, x); 261 } catch(RemoteException e) { 262 throw new java.sql.SQLException (e.getMessage()); 263 } 264 } 265 266 273 public void setTime(int parameterIndex, java.sql.Time x) 274 throws SQLException { 275 try { 276 rmiPrepStmt_.setTime(parameterIndex, x); 277 } catch(RemoteException e) { 278 throw new java.sql.SQLException (e.getMessage()); 279 } 280 } 281 282 290 public void setTimestamp(int parameterIndex, java.sql.Timestamp x) 291 throws SQLException { 292 try { 293 rmiPrepStmt_.setTimestamp(parameterIndex, x); 294 } catch(RemoteException e) { 295 throw new java.sql.SQLException (e.getMessage()); 296 } 297 } 298 299 314 316 public void setAsciiStream(int parameterIndex, java.io.InputStream x, 317 int length) throws SQLException { 318 try { 319 321 337 338 BufferedInputStream s = new BufferedInputStream(x); 339 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 340 byte buf[] = new byte[256]; 341 int br; 342 while((br = s.read(buf)) >= 0){ 343 if (br > 0) bos.write(buf, 0, br); 344 } 345 s.close(); 346 rmiPrepStmt_.setAsciiStream(parameterIndex, bos.toByteArray(), length); 347 348 } catch(RemoteException e) { 349 throw new java.sql.SQLException (e.getMessage()); 350 } catch(IOException e) { 351 throw new java.sql.SQLException (e.getMessage()); 352 } 353 } 354 355 371 373 public void setUnicodeStream(int parameterIndex, java.io.InputStream x, 374 int length) throws SQLException { 375 try { 376 378 394 395 BufferedInputStream s = new BufferedInputStream(x); 396 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 397 byte buf[] = new byte[256]; 398 int br; 399 while((br = s.read(buf)) >= 0){ 400 if (br > 0) bos.write(buf, 0, br); 401 } 402 s.close(); 403 rmiPrepStmt_.setUnicodeStream(parameterIndex, bos.toByteArray(), length); 404 405 } catch(RemoteException e) { 406 throw new java.sql.SQLException (e.getMessage()); 407 } catch(IOException e) { 408 throw new java.sql.SQLException (e.getMessage()); 409 } 410 } 411 412 426 428 public void setBinaryStream(int parameterIndex, java.io.InputStream x, 429 int length) throws SQLException { 430 try { 431 448 449 BufferedInputStream s = new BufferedInputStream(x); 450 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 451 byte buf[] = new byte[256]; 452 int br; 453 while((br = s.read(buf)) >= 0){ 454 if (br > 0) bos.write(buf, 0, br); 455 } 456 s.close(); 457 rmiPrepStmt_.setBinaryStream(parameterIndex, bos.toByteArray(), length); 458 459 465 } catch(RemoteException e) { 466 throw new java.sql.SQLException (e.getMessage()); 467 } catch(IOException e) { 468 throw new java.sql.SQLException (e.getMessage()); 469 } 470 } 471 472 479 public void clearParameters() throws SQLException { 480 try { 481 rmiPrepStmt_.clearParameters(); 482 } catch(RemoteException e) { 483 throw new java.sql.SQLException (e.getMessage()); 484 } 485 } 486 487 490 511 public void setObject(int parameterIndex, Object x, int targetSqlType, 512 int scale) throws SQLException { 513 try { 514 rmiPrepStmt_.setObject(parameterIndex, x, targetSqlType, scale); 515 } catch(RemoteException e) { 516 throw new java.sql.SQLException (e.getMessage()); 517 } 518 } 519 520 523 public void setObject(int parameterIndex, Object x, int targetSqlType) 524 throws SQLException { 525 try { 526 rmiPrepStmt_.setObject(parameterIndex, x, targetSqlType); 527 } catch(RemoteException e) { 528 throw new java.sql.SQLException (e.getMessage()); 529 } 530 } 531 532 548 public void setObject(int parameterIndex, Object x) throws SQLException { 549 try { 550 rmiPrepStmt_.setObject(parameterIndex, x); 551 } catch(RemoteException e) { 552 throw new java.sql.SQLException (e.getMessage()); 553 } 554 } 555 556 563 public boolean execute() throws SQLException { 564 try { 565 return rmiPrepStmt_.execute(); 566 } catch(RemoteException e) { 567 throw new java.sql.SQLException (e.getMessage()); 568 } 569 } 570 571 572 576 public void setTimestamp(int parameterIndex, Timestamp x, 577 java.util.Calendar cal) throws SQLException { 578 try { 579 rmiPrepStmt_.setTimestamp(parameterIndex,x,cal); 580 } catch(RemoteException e) { 581 throw new java.sql.SQLException (e.getMessage()); 582 } 583 } 584 585 public void setTime(int parameterIndex, Time x, java.util.Calendar cal) 586 throws SQLException { 587 try { 588 rmiPrepStmt_.setTime(parameterIndex,x,cal); 589 } catch(RemoteException e) { 590 throw new java.sql.SQLException (e.getMessage()); 591 } 592 } 593 594 public void setRef(int i,Ref x) throws SQLException { 595 try { 596 rmiPrepStmt_.setRef(i,x); 597 } catch(RemoteException e) { 598 throw new java.sql.SQLException (e.getMessage()); 599 } 600 } 601 602 public void setNull(int paramIndex, int sqlType, String typeName) 603 throws SQLException { 604 try { 605 rmiPrepStmt_.setNull(paramIndex,sqlType,typeName); 606 } catch(RemoteException e) { 607 throw new java.sql.SQLException (e.getMessage()); 608 } 609 } 610 611 public void setDate(int parameterIndex, Date x, 612 java.util.Calendar cal) throws SQLException { 613 try { 614 rmiPrepStmt_.setDate(parameterIndex,x,cal); 615 } catch(RemoteException e) { 616 throw new java.sql.SQLException (e.getMessage()); 617 } 618 } 619 620 public void setClob(int i, Clob x) throws SQLException { 621 try { 622 rmiPrepStmt_.setClob(i,x); 623 } catch(RemoteException e) { 624 throw new java.sql.SQLException (e.getMessage()); 625 } 626 } 627 628 public void setCharacterStream(int parameterIndex, java.io.Reader reader, 629 int length) throws SQLException { 630 try { 631 633 rmiPrepStmt_.setCharacterStream(parameterIndex, 634 RJSerializer.toCharArray(reader), length); 635 636 } catch(Exception e) { 637 throw new java.sql.SQLException (e.getMessage()); 638 } 639 } 640 641 public void setBlob(int i, Blob x) throws SQLException { 642 try { 643 rmiPrepStmt_.setBlob(i,x); 644 } catch(RemoteException e) { 645 throw new java.sql.SQLException (e.getMessage()); 646 } 647 } 648 649 public void setArray(int i, Array x) throws SQLException { 650 try { 651 rmiPrepStmt_.setArray(i,x); 652 } catch(RemoteException e) { 653 throw new java.sql.SQLException (e.getMessage()); 654 } 655 } 656 657 public ResultSetMetaData getMetaData() throws SQLException { 658 try { 659 return new RJResultSetMetaData(rmiPrepStmt_.getMetaData()); 660 } catch(RemoteException e) { 661 throw new java.sql.SQLException (e.getMessage()); 662 } 663 } 664 665 public void addBatch() throws SQLException { 666 try { 667 rmiPrepStmt_.addBatch(); 668 } catch(RemoteException e) { 669 throw new java.sql.SQLException (e.getMessage()); 670 } 671 } 672 673 public void setURL(int parameterIndex, java.net.URL x) throws SQLException { 675 try { 676 rmiPrepStmt_.setURL(parameterIndex, x); 677 } catch(RemoteException e) { 678 throw new java.sql.SQLException (e.getMessage()); 679 } 680 } 681 682 683 public ParameterMetaData getParameterMetaData() throws SQLException { 684 try { 685 return new RJParameterMetaData(rmiPrepStmt_.getParameterMetaData()); 686 } catch(RemoteException e) { 687 throw new java.sql.SQLException (e.getMessage()); 688 } 689 } 690 691 }; 692 693 | Popular Tags |