1 2 10 11 package org.objectweb.rmijdbc; 12 13 import java.sql.*; 14 import java.rmi.RemoteException ; 15 import java.util.Properties ; 16 18 38 public class RJConnection 39 implements java.sql.Connection , java.io.Serializable { 40 41 RJConnectionInterface rmiConnection_; 42 43 protected RJConnection(RJConnectionInterface rmiconn) { 44 rmiConnection_ = rmiconn; 45 } 46 47 public RJConnection(RJDriverInterface drv, String url, Properties info) 48 throws Exception { 49 50 rmiConnection_ = drv.connect(url, info); 52 53 if(rmiConnection_ == null) { 54 throw new SQLException("Underlying driver couldn\'t establish the connection: connect() returned null, check the configuration"); 55 } 56 } 57 58 59 67 public java.sql.Statement createStatement() throws SQLException { 68 try { 69 return new RJStatement(rmiConnection_.createStatement(), this); 70 } catch(RemoteException e) { 71 throw new java.sql.SQLException (e.getMessage()); 72 } 73 } 74 75 96 public java.sql.PreparedStatement prepareStatement(String sql) 97 throws SQLException { 98 try { 99 return new RJPreparedStatement(rmiConnection_.prepareStatement(sql), 100 this); 101 } catch(RemoteException e) { 102 throw new java.sql.SQLException (e.getMessage()); 103 } 104 } 105 106 126 public java.sql.CallableStatement prepareCall(String sql) 127 throws SQLException { 128 try { 129 return new RJCallableStatement(rmiConnection_.prepareCall(sql), this); 130 } catch(RemoteException e) { 131 throw new java.sql.SQLException (e.getMessage()); 132 } 133 } 134 135 145 public String nativeSQL(String sql) throws SQLException { 146 try { 147 return rmiConnection_.nativeSQL(sql); 148 } catch(RemoteException e) { 149 throw new java.sql.SQLException (e.getMessage()); 150 } 151 } 152 153 173 public void setAutoCommit(boolean autoCommit) throws SQLException { 174 try { 175 rmiConnection_.setAutoCommit(autoCommit); 176 } catch(RemoteException e) { 177 throw new java.sql.SQLException (e.getMessage()); 178 } 179 } 180 181 186 public boolean getAutoCommit() throws SQLException { 187 try { 188 return rmiConnection_.getAutoCommit(); 189 } catch(RemoteException e) { 190 throw new java.sql.SQLException (e.getMessage()); 191 } 192 } 193 194 202 public void commit() throws SQLException { 203 try { 204 rmiConnection_.commit(); 205 } catch(RemoteException e) { 206 throw new java.sql.SQLException (e.getMessage()); 207 } 208 } 209 210 218 public void rollback() throws SQLException { 219 try { 220 rmiConnection_.rollback(); 221 } catch(RemoteException e) { 222 throw new java.sql.SQLException (e.getMessage()); 223 } 224 } 225 226 236 public void close() throws SQLException { 237 try { 238 rmiConnection_.close(); 239 } catch(RemoteException e) { 240 throw new java.sql.SQLException (e.getMessage()); 241 } 242 } 243 244 249 public boolean isClosed() throws SQLException { 250 try { 251 return rmiConnection_.isClosed(); 252 } catch(RemoteException e) { 253 throw new java.sql.SQLException (e.getMessage()); 254 } 255 } 256 257 260 269 public java.sql.DatabaseMetaData getMetaData() throws SQLException { 270 try { 271 return new RJDatabaseMetaData(rmiConnection_.getMetaData(), this); 272 } catch(RemoteException e) { 273 throw new java.sql.SQLException (e.getMessage()); 274 } 275 } 276 277 287 public void setReadOnly(boolean readOnly) throws SQLException { 288 try { 289 rmiConnection_.setReadOnly(readOnly); 290 } catch(RemoteException e) { 291 throw new java.sql.SQLException (e.getMessage()); 292 } 293 } 294 295 300 public boolean isReadOnly() throws SQLException { 301 try { 302 return rmiConnection_.isReadOnly(); 303 } catch(RemoteException e) { 304 throw new java.sql.SQLException (e.getMessage()); 305 } 306 } 307 308 313 public void setCatalog(String catalog) throws SQLException { 314 try { 315 rmiConnection_.setCatalog(catalog); 316 } catch(RemoteException e) { 317 throw new java.sql.SQLException (e.getMessage()); 318 } 319 } 320 321 326 public String getCatalog() throws SQLException { 327 try { 328 return rmiConnection_.getCatalog(); 329 } catch(RemoteException e) { 330 throw new java.sql.SQLException (e.getMessage()); 331 } 332 } 333 334 337 int TRANSACTION_NONE = 0; 338 339 342 int TRANSACTION_READ_UNCOMMITTED = 1; 343 344 348 int TRANSACTION_READ_COMMITTED = 2; 349 350 354 int TRANSACTION_REPEATABLE_READ = 4; 355 356 359 int TRANSACTION_SERIALIZABLE = 8; 360 361 374 public void setTransactionIsolation(int level) throws SQLException { 375 try { 376 rmiConnection_.setTransactionIsolation(level); 377 } catch(RemoteException e) { 378 throw new java.sql.SQLException (e.getMessage()); 379 } 380 } 381 382 387 public int getTransactionIsolation() throws SQLException { 388 try { 389 return rmiConnection_.getTransactionIsolation(); 390 } catch(RemoteException e) { 391 throw new java.sql.SQLException (e.getMessage()); 392 } 393 } 394 395 404 public SQLWarning getWarnings() throws SQLException { 405 try { 406 return rmiConnection_.getWarnings(); 407 } catch(RemoteException e) { 408 throw new java.sql.SQLException (e.getMessage()); 409 } 410 } 411 412 416 public void clearWarnings() throws SQLException { 417 try { 418 rmiConnection_.clearWarnings(); 419 } catch(RemoteException e) { 420 throw new java.sql.SQLException (e.getMessage()); 421 } 422 } 423 424 425 430 public void setTypeMap(java.util.Map map) throws SQLException { 431 try { 432 rmiConnection_.setTypeMap(map); 433 } catch(RemoteException e) { 434 throw new java.sql.SQLException (e.getMessage()); 435 } 436 } 437 438 public PreparedStatement prepareStatement(String sql, int resultSetType, 439 int resultSetConcurrency) throws SQLException { 440 try { 441 return new RJPreparedStatement( 442 rmiConnection_.prepareStatement(sql, resultSetType, 443 resultSetConcurrency), this); 444 } catch(RemoteException e) { 445 throw new java.sql.SQLException (e.getMessage()); 446 } 447 } 448 449 public CallableStatement prepareCall(String sql, int resultSetType, 450 int resultSetConcurrency) throws SQLException { 451 try { 452 return new RJCallableStatement( 453 rmiConnection_.prepareCall(sql,resultSetType,resultSetConcurrency), 454 this); 455 } catch(RemoteException e) { 456 throw new java.sql.SQLException (e.getMessage()); 457 } 458 } 459 460 461 public java.util.Map getTypeMap() throws SQLException { 462 try { 463 return rmiConnection_.getTypeMap(); 464 } catch(RemoteException e) { 465 throw new java.sql.SQLException (e.getMessage()); 466 } 467 } 468 469 public Statement createStatement(int resultSetType, int resultSetConcurrency) 470 throws SQLException { 471 try { 472 return new RJStatement( 473 rmiConnection_.createStatement(resultSetType,resultSetConcurrency), 474 this); 475 } catch(RemoteException e) { 476 throw new java.sql.SQLException (e.getMessage()); 477 } 478 } 479 480 490 491 493 public void setHoldability(int holdability) throws SQLException { 494 try { 495 rmiConnection_.setHoldability(holdability); 496 } catch(RemoteException e) { 497 throw new java.sql.SQLException (e.getMessage()); 498 } 499 } 500 501 public int getHoldability() throws SQLException { 502 try { 503 return rmiConnection_.getHoldability(); 504 } catch(RemoteException e) { 505 throw new java.sql.SQLException (e.getMessage()); 506 } 507 } 508 509 510 public Savepoint setSavepoint() throws SQLException { 511 try { 512 return new RJSavepoint(rmiConnection_.setSavepoint()); 513 } catch(RemoteException e) { 514 throw new java.sql.SQLException (e.getMessage()); 515 } 516 } 517 518 public Savepoint setSavepoint(String name) throws SQLException { 519 try { 520 return new RJSavepoint(rmiConnection_.setSavepoint(name)); 521 } catch(RemoteException e) { 522 throw new java.sql.SQLException (e.getMessage()); 523 } 524 } 525 526 public void rollback(Savepoint savepoint) throws SQLException { 527 try { 528 rmiConnection_.rollback(savepoint); 529 } catch(RemoteException e) { 530 throw new java.sql.SQLException (e.getMessage()); 531 } 532 } 533 534 public void releaseSavepoint(Savepoint savepoint) throws SQLException { 535 try { 536 rmiConnection_.releaseSavepoint(savepoint); 537 } catch(RemoteException e) { 538 throw new java.sql.SQLException (e.getMessage()); 539 } 540 } 541 542 public Statement createStatement(int resultSetType, 543 int resultSetConcurrency, int resultSetHoldability) throws SQLException { 544 try { 545 return new RJStatement( 546 rmiConnection_.createStatement(resultSetType, resultSetConcurrency, 547 resultSetHoldability), this); 548 } catch(RemoteException e) { 549 throw new java.sql.SQLException (e.getMessage()); 550 } 551 } 552 553 public PreparedStatement prepareStatement(String sql, int resultSetType, 554 int resultSetConcurrency, int resultSetHoldability) throws SQLException { 555 try { 556 return new RJPreparedStatement( 557 rmiConnection_.prepareStatement(sql, resultSetType, 558 resultSetConcurrency, resultSetHoldability), this); 559 } catch(RemoteException e) { 560 throw new java.sql.SQLException (e.getMessage()); 561 } 562 } 563 564 565 public CallableStatement prepareCall(String sql, int resultSetType, 566 int resultSetConcurrency, int resultSetHoldability) throws SQLException { 567 try { 568 return new RJCallableStatement( 569 rmiConnection_.prepareCall(sql, resultSetType, resultSetConcurrency, 570 resultSetHoldability), this); 571 } catch(RemoteException e) { 572 throw new java.sql.SQLException (e.getMessage()); 573 } 574 } 575 576 public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) 577 throws SQLException { 578 try { 579 return new RJPreparedStatement( 580 rmiConnection_.prepareStatement(sql, autoGeneratedKeys), this); 581 } catch(RemoteException e) { 582 throw new java.sql.SQLException (e.getMessage()); 583 } 584 } 585 586 public PreparedStatement prepareStatement(String sql, int columnIndexes[]) 587 throws SQLException { 588 try { 589 return new RJPreparedStatement( 590 rmiConnection_.prepareStatement(sql, columnIndexes), this); 591 } catch(RemoteException e) { 592 throw new java.sql.SQLException (e.getMessage()); 593 } 594 } 595 596 public PreparedStatement prepareStatement(String sql, String columnNames[]) 597 throws SQLException { 598 try { 599 return new RJPreparedStatement( 600 rmiConnection_.prepareStatement(sql, columnNames), this); 601 } catch(RemoteException e) { 602 throw new java.sql.SQLException (e.getMessage()); 603 } 604 } 605 606 }; 607 608 | Popular Tags |