1 14 package org.compiere.util; 15 16 import java.util.*; 17 import java.sql.ResultSet ; 18 import java.sql.SQLException ; 19 import java.math.BigDecimal ; 20 import java.sql.Date ; 21 import java.sql.Time ; 22 import java.sql.Timestamp ; 23 import java.sql.Ref ; 24 import java.sql.Blob ; 25 import java.sql.Clob ; 26 import java.sql.Array ; 27 import java.sql.ResultSetMetaData ; 28 import java.util.Calendar ; 30 import java.net.URL ; 31 import java.sql.ParameterMetaData ; 32 import java.sql.SQLWarning ; 33 import java.sql.Connection ; 34 import java.sql.PreparedStatement ; 35 import java.io.*; 37 import javax.sql.RowSet ; 38 39 40 import org.compiere.interfaces.Server; 41 import org.compiere.db.CConnection; 42 import org.compiere.db.CompiereDatabase; 43 import java.rmi.*; 44 45 51 public class CompiereStatement implements PreparedStatement  52 { 53 60 public CompiereStatement (String sql0, int resultSetType, int resultSetConcurrency) 61 { 62 String sql = DB.getDatabase().convertStatement(sql0); 64 65 boolean remote = Ini.isClient() && Ini.getPropertyBool(Ini.P_OBJECTS); 67 if (remote) remote = CConnection.get().isAppsServerOK(false); 69 if (remote) 71 m_vo = new CompiereStatementVO (sql, resultSetType, resultSetConcurrency); 72 else { 74 try 75 { 76 Connection conn = null; 77 if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE) 78 conn = DB.getConnectionRW(); 79 else 80 conn = DB.getConnectionRO(); 81 m_pstmt = conn.prepareStatement (sql, resultSetType, resultSetConcurrency); 82 return; 83 } 84 catch (SQLException e) 85 { 86 log.error(sql, e); 87 } 88 } 89 } 91 95 public CompiereStatement (CompiereStatementVO vo) 96 { 97 m_vo = vo; 99 } 101 102 private transient Logger log = Logger.getCLogger (getClass()); 103 104 private transient PreparedStatement m_pstmt = null; 105 106 private CompiereStatementVO m_vo = null; 107 108 113 public ResultSet executeQuery () throws SQLException  114 { 115 if (m_pstmt != null) return m_pstmt.executeQuery(); 117 Server server = CConnection.get().getServer(); 120 if (Log.isTraceLevel(10)) 121 log.debug("executeQuery - server => " + m_vo); 122 try 123 { 124 if (server != null) 125 { 126 ResultSet rs = server.stmt_getRowSet (m_vo); 127 if (rs == null) 128 log.warn("executeQuery - ResultSet is null - " + m_vo); 129 m_vo.clearParameters(); return rs; 131 } 132 log.error("executeQuery - AppsServer not found"); 133 } 134 catch (RemoteException ex) 135 { 136 log.error("executeQuery - AppsServer error", ex); 137 } 138 CConnection.get().isAppsServerOK(true); 140 PreparedStatement pstmt = local_getPreparedStatement(); 141 m_vo.clearParameters(); return pstmt.executeQuery(); 143 } 145 151 public ResultSet executeQuery (String sql0) throws SQLException  152 { 153 String sql = DB.getDatabase().convertStatement(sql0); 155 if (m_pstmt != null) return m_pstmt.executeQuery(sql); 157 m_vo.setSql(sql); 159 return executeQuery(); 160 } 162 163 164 169 public int executeUpdate () throws SQLException  170 { 171 if (m_pstmt != null) 172 return m_pstmt.executeUpdate(); 173 Server server = CConnection.get().getServer(); 176 if (Log.isTraceLevel(10)) 177 log.debug("executeUpdate - server => " + m_vo); 178 try 179 { 180 if (server != null) 181 { 182 int result = server.stmt_executeUpdate (m_vo); 183 m_vo.clearParameters(); return result; 185 } 186 log.error("executeUpdate - AppsServer not found"); 187 } 188 catch (RemoteException ex) 189 { 190 log.error("executeUpdate - AppsServer error", ex); 191 } 192 CConnection.get().isAppsServerOK(true); 194 PreparedStatement pstmt = local_getPreparedStatement(); 195 m_vo.clearParameters(); return pstmt.executeUpdate(); 197 } 199 205 public int executeUpdate (String sql0) throws SQLException  206 { 207 String sql = DB.getDatabase().convertStatement(sql0); 209 if (m_pstmt != null) 210 return m_pstmt.executeUpdate(sql); 211 m_vo.setSql(sql); 213 return executeUpdate(); 214 } 216 public int executeUpdate (String sql, int autoGeneratedKeys) throws SQLException  217 { 218 if (m_pstmt != null) 219 return m_pstmt.executeUpdate(sql, autoGeneratedKeys); 220 throw new java.lang.UnsupportedOperationException ("Method executeUpdate() not yet implemented."); 221 } 222 223 public int executeUpdate (String sql, int[] columnIndexes) throws SQLException  224 { 225 if (m_pstmt != null) 226 return m_pstmt.executeUpdate(sql, columnIndexes); 227 throw new java.lang.UnsupportedOperationException ("Method executeUpdate() not yet implemented."); 228 } 229 230 public int executeUpdate (String sql, String [] columnNames) throws SQLException  231 { 232 if (m_pstmt != null) 233 return m_pstmt.executeUpdate(sql, columnNames); 234 throw new java.lang.UnsupportedOperationException ("Method executeUpdate() not yet implemented."); 235 } 236 237 public boolean execute () throws SQLException  238 { 239 if (m_pstmt != null) 240 return m_pstmt.execute(); 241 throw new java.lang.UnsupportedOperationException ("Method execute() not yet implemented."); 242 } 243 244 public boolean execute (String sql, int autoGeneratedKeys) throws SQLException  245 { 246 if (m_pstmt != null) 247 return m_pstmt.execute(sql, autoGeneratedKeys); 248 throw new java.lang.UnsupportedOperationException ("Method execute() not yet implemented."); 249 } 250 251 public boolean execute (String sql, int[] columnIndexes) throws SQLException  252 { 253 if (m_pstmt != null) 254 return m_pstmt.execute(sql, columnIndexes); 255 throw new java.lang.UnsupportedOperationException ("Method execute() not yet implemented."); 256 } 257 258 public boolean execute (String sql, String [] columnNames) throws SQLException  259 { 260 if (m_pstmt != null) 261 return m_pstmt.execute(sql, columnNames); 262 throw new java.lang.UnsupportedOperationException ("Method execute() not yet implemented."); 263 } 264 265 266 public ResultSetMetaData getMetaData () throws SQLException  267 { 268 if (m_pstmt != null) 269 return m_pstmt.getMetaData (); 270 else 271 throw new java.lang.UnsupportedOperationException ("Method getMetaData() not yet implemented."); 272 } 273 274 public ParameterMetaData getParameterMetaData () throws SQLException  275 { 276 if (m_pstmt != null) 277 return m_pstmt.getParameterMetaData(); 278 throw new java.lang.UnsupportedOperationException ("Method getParameterMetaData() not yet implemented."); 279 } 280 281 285 public void close () throws SQLException  286 { 287 if (m_pstmt != null) 288 m_pstmt.close(); 289 } 291 292 293 298 public int getMaxFieldSize () throws SQLException  299 { 300 if (m_pstmt != null) 301 return m_pstmt.getMaxFieldSize(); 302 throw new java.lang.UnsupportedOperationException ("Method getMaxFieldSize() not yet implemented."); 303 } 304 305 public void setMaxFieldSize (int max) throws SQLException  306 { 307 if (m_pstmt != null) 308 m_pstmt.setMaxFieldSize(max); 309 else 310 throw new java.lang.UnsupportedOperationException ("Method setMaxFieldSize() not yet implemented."); 311 } 312 313 public int getMaxRows () throws SQLException  314 { 315 if (m_pstmt != null) 316 return m_pstmt.getMaxRows(); 317 throw new java.lang.UnsupportedOperationException ("Method getMaxRows() not yet implemented."); 318 } 319 320 public void setMaxRows (int max) throws SQLException  321 { 322 if (m_pstmt != null) 323 m_pstmt.setMaxRows(max); 324 else 325 throw new java.lang.UnsupportedOperationException ("Method setMaxRows() not yet implemented."); 326 } 327 328 329 330 335 public void addBatch (String sql) throws SQLException  336 { 337 if (m_pstmt != null) 338 m_pstmt.addBatch(sql); 339 else 340 throw new java.lang.UnsupportedOperationException ("Method addBatch() not yet implemented."); 341 } 342 343 public void clearBatch () throws SQLException  344 { 345 if (m_pstmt != null) 346 m_pstmt.clearBatch(); 347 else 348 throw new java.lang.UnsupportedOperationException ("Method clearBatch() not yet implemented."); 349 } 350 351 public int[] executeBatch () throws SQLException  352 { 353 if (m_pstmt != null) 354 return m_pstmt.executeBatch(); 355 throw new java.lang.UnsupportedOperationException ("Method executeBatch() not yet implemented."); 356 } 357 358 public Connection getConnection () throws SQLException  359 { 360 if (m_pstmt != null) 361 return m_pstmt.getConnection(); 362 throw new java.lang.UnsupportedOperationException ("Method getConnection() not yet implemented."); 363 } 364 365 public boolean getMoreResults (int current) throws SQLException  366 { 367 if (m_pstmt != null) 368 return m_pstmt.getMoreResults(current); 369 throw new java.lang.UnsupportedOperationException ("Method getMoreResults() not yet implemented."); 370 } 371 372 public ResultSet getGeneratedKeys () throws SQLException  373 { 374 if (m_pstmt != null) 375 return m_pstmt.getGeneratedKeys(); 376 throw new java.lang.UnsupportedOperationException ("Method getGeneratedKeys() not yet implemented."); 377 } 378 379 public int getResultSetHoldability () throws SQLException  380 { 381 if (m_pstmt != null) 382 return m_pstmt.getResultSetHoldability(); 383 throw new java.lang.UnsupportedOperationException ("Method getResultSetHoldability() not yet implemented."); 384 } 385 386 public void setEscapeProcessing (boolean enable) throws SQLException  387 { 388 if (m_pstmt != null) 389 m_pstmt.setEscapeProcessing(enable); 390 else 391 throw new java.lang.UnsupportedOperationException ("Method setEscapeProcessing() not yet implemented."); 392 } 393 394 public int getQueryTimeout () throws SQLException  395 { 396 if (m_pstmt != null) 397 return m_pstmt.getQueryTimeout(); 398 throw new java.lang.UnsupportedOperationException ("Method getQueryTimeout() not yet implemented."); 399 } 400 401 public void setQueryTimeout (int seconds) throws SQLException  402 { 403 if (m_pstmt != null) 404 m_pstmt.setQueryTimeout (seconds); 405 else 406 throw new java.lang.UnsupportedOperationException ("Method setQueryTimeout() not yet implemented."); 407 } 408 409 public void cancel () throws SQLException  410 { 411 if (m_pstmt != null) 412 m_pstmt.cancel(); 413 else 414 throw new java.lang.UnsupportedOperationException ("Method cancel() not yet implemented."); 415 } 416 417 public SQLWarning getWarnings () throws SQLException  418 { 419 if (m_pstmt != null) 420 return m_pstmt.getWarnings(); 421 throw new java.lang.UnsupportedOperationException ("Method getWarnings() not yet implemented."); 422 } 423 424 public void clearWarnings () throws SQLException  425 { 426 if (m_pstmt != null) 427 m_pstmt.clearWarnings(); 428 else 429 throw new java.lang.UnsupportedOperationException ("Method clearWarnings() not yet implemented."); 430 } 431 432 public void setCursorName (String name) throws SQLException  433 { 434 if (m_pstmt != null) 435 m_pstmt.setCursorName(name); 436 else 437 throw new java.lang.UnsupportedOperationException ("Method setCursorName() not yet implemented."); 438 } 439 440 public boolean execute (String sql) throws SQLException  441 { 442 if (m_pstmt != null) 443 return m_pstmt.execute(sql); 444 throw new java.lang.UnsupportedOperationException ("Method execute() not yet implemented."); 445 } 446 447 public ResultSet getResultSet () throws SQLException  448 { 449 if (m_pstmt != null) 450 return m_pstmt.getResultSet(); 451 throw new java.lang.UnsupportedOperationException ("Method getResultSet() not yet implemented."); 452 } 453 454 public int getUpdateCount () throws SQLException  455 { 456 if (m_pstmt != null) 457 return m_pstmt.getUpdateCount(); 458 throw new java.lang.UnsupportedOperationException ("Method getUpdateCount() not yet implemented."); 459 } 460 461 public boolean getMoreResults () throws SQLException  462 { 463 if (m_pstmt != null) 464 return m_pstmt.getMoreResults(); 465 throw new java.lang.UnsupportedOperationException ("Method getMoreResults() not yet implemented."); 466 } 467 468 public void setFetchDirection (int direction) throws SQLException  469 { 470 if (m_pstmt != null) 471 m_pstmt.setFetchDirection(direction); 472 else 473 throw new java.lang.UnsupportedOperationException ("Method setFetchDirection() not yet implemented."); 474 } 475 476 public int getFetchDirection () throws SQLException  477 { 478 if (m_pstmt != null) 479 return m_pstmt.getFetchDirection(); 480 throw new java.lang.UnsupportedOperationException ("Method getFetchDirection() not yet implemented."); 481 } 482 483 public void setFetchSize (int rows) throws SQLException  484 { 485 if (m_pstmt != null) 486 m_pstmt.setFetchSize(rows); 487 else 488 throw new java.lang.UnsupportedOperationException ("Method setFetchSize() not yet implemented."); 489 } 490 491 public int getFetchSize () throws SQLException  492 { 493 if (m_pstmt != null) 494 return m_pstmt.getFetchSize(); 495 throw new java.lang.UnsupportedOperationException ("Method getFetchSize() not yet implemented."); 496 } 497 498 public int getResultSetConcurrency () throws SQLException  499 { 500 if (m_pstmt != null) 501 return m_pstmt.getResultSetConcurrency(); 502 throw new java.lang.UnsupportedOperationException ("Method getResultSetConcurrency() not yet implemented."); 503 } 504 505 public int getResultSetType () throws SQLException  506 { 507 if (m_pstmt != null) 508 return m_pstmt.getResultSetType(); 509 throw new java.lang.UnsupportedOperationException ("Method getResultSetType() not yet implemented."); 510 } 511 512 public void addBatch () throws SQLException  513 { 514 if (m_pstmt != null) 515 m_pstmt.addBatch (); 516 else 517 throw new java.lang.UnsupportedOperationException ("Method addBatch() not yet implemented."); 518 } 519 520 521 522 528 public void setNull (int parameterIndex, int sqlType) throws SQLException  529 { 530 if (m_pstmt != null) 531 m_pstmt.setNull (parameterIndex, sqlType); 532 else 533 m_vo.setParameter(parameterIndex, new NullParameter(sqlType)); 534 } 536 public void setNull (int parameterIndex, int sqlType, String typeName) throws SQLException  537 { 538 if (m_pstmt != null) 539 m_pstmt.setNull (parameterIndex, sqlType); 540 else 541 m_vo.setParameter(parameterIndex, new NullParameter(sqlType)); 542 } 543 544 public void setBoolean (int parameterIndex, boolean x) throws SQLException  545 { 546 if (m_pstmt != null) 547 m_pstmt.setBoolean (parameterIndex, x); 548 else 549 m_vo.setParameter(parameterIndex, new Boolean (x)); 550 } 551 552 public void setByte (int parameterIndex, byte x) throws SQLException  553 { 554 if (m_pstmt != null) 555 m_pstmt.setByte (parameterIndex, x); 556 else 557 m_vo.setParameter(parameterIndex, new Byte (x)); 558 } 559 560 public void setShort (int parameterIndex, short x) throws SQLException  561 { 562 if (m_pstmt != null) 563 m_pstmt.setShort (parameterIndex, x); 564 else 565 m_vo.setParameter(parameterIndex, new Short (x)); 566 } 567 568 public void setInt (int parameterIndex, int x) throws SQLException  569 { 570 if (m_pstmt != null) 571 m_pstmt.setInt (parameterIndex, x); 572 else 573 m_vo.setParameter(parameterIndex, new Integer (x)); 574 } 575 576 public void setLong (int parameterIndex, long x) throws SQLException  577 { 578 if (m_pstmt != null) 579 m_pstmt.setLong (parameterIndex, x); 580 else 581 m_vo.setParameter(parameterIndex, new Long (x)); 582 } 583 584 public void setFloat (int parameterIndex, float x) throws SQLException  585 { 586 if (m_pstmt != null) 587 m_pstmt.setFloat (parameterIndex, x); 588 else 589 m_vo.setParameter(parameterIndex, new Float (x)); 590 } 591 592 public void setDouble (int parameterIndex, double x) throws SQLException  593 { 594 if (m_pstmt != null) 595 m_pstmt.setDouble (parameterIndex, x); 596 else 597 m_vo.setParameter(parameterIndex, new Double (x)); 598 } 599 600 public void setBigDecimal (int parameterIndex, BigDecimal x) throws SQLException  601 { 602 if (m_pstmt != null) 603 m_pstmt.setBigDecimal (parameterIndex, x); 604 else 605 m_vo.setParameter(parameterIndex, x); 606 } 607 608 public void setString (int parameterIndex, String x) throws SQLException  609 { 610 if (m_pstmt != null) 611 m_pstmt.setString (parameterIndex, x); 612 else 613 m_vo.setParameter(parameterIndex, x); 614 } 615 616 public void setBytes (int parameterIndex, byte[] x) throws SQLException  617 { 618 if (m_pstmt != null) 619 m_pstmt.setBytes (parameterIndex, x); 620 else 621 throw new java.lang.UnsupportedOperationException ("Method setBytes() not yet implemented."); 622 } 623 624 public void setDate (int parameterIndex, Date x) throws SQLException  625 { 626 if (m_pstmt != null) 627 m_pstmt.setDate (parameterIndex, x); 628 else 629 m_vo.setParameter(parameterIndex, x); 630 } 631 632 public void setTime (int parameterIndex, Time x) throws SQLException  633 { 634 if (m_pstmt != null) 635 m_pstmt.setTime (parameterIndex, x); 636 else 637 m_vo.setParameter(parameterIndex, x); 638 } 639 640 public void setTimestamp (int parameterIndex, Timestamp x) throws SQLException  641 { 642 if (m_pstmt != null) 643 m_pstmt.setTimestamp (parameterIndex, x); 644 else 645 m_vo.setParameter(parameterIndex, x); 646 } 647 648 public void setAsciiStream (int parameterIndex, InputStream x, int length) throws SQLException  649 { 650 if (m_pstmt != null) 651 m_pstmt.setAsciiStream (parameterIndex, x, length); 652 else 653 throw new java.lang.UnsupportedOperationException ("Method setAsciiStream() not yet implemented."); 654 } 655 656 664 public void setUnicodeStream (int parameterIndex, InputStream x, int length) throws SQLException  665 { 666 throw new UnsupportedOperationException ("Method setUnicodeStream() not yet implemented."); 667 } 668 669 public void setBinaryStream (int parameterIndex, InputStream x, int length) throws SQLException  670 { 671 if (m_pstmt != null) 672 m_pstmt.setBinaryStream (parameterIndex, x, length); 673 else 674 throw new java.lang.UnsupportedOperationException ("Method setBinaryStream() not yet implemented."); 675 } 676 677 public void clearParameters () throws SQLException  678 { 679 if (m_pstmt != null) 680 m_pstmt.clearParameters (); 681 else 682 m_vo.clearParameters(); 683 } 684 685 public void setObject (int parameterIndex, Object x, int targetSqlType, int scale) throws SQLException  686 { 687 if (m_pstmt != null) 688 m_pstmt.setObject (parameterIndex, x, targetSqlType, scale); 689 else 690 throw new java.lang.UnsupportedOperationException ("Method setObject() not yet implemented."); 691 } 692 693 public void setObject (int parameterIndex, Object x, int targetSqlType) throws SQLException  694 { 695 if (m_pstmt != null) 696 m_pstmt.setObject (parameterIndex, x); 697 else 698 throw new java.lang.UnsupportedOperationException ("Method setObject() not yet implemented."); 699 } 700 701 public void setObject (int parameterIndex, Object x) throws SQLException  702 { 703 if (m_pstmt != null) 704 m_pstmt.setObject (parameterIndex, x); 705 else 706 m_vo.setParameter(parameterIndex, x); 707 } 708 709 public void setCharacterStream (int parameterIndex, Reader reader, int length) throws SQLException  710 { 711 if (m_pstmt != null) 712 m_pstmt.setCharacterStream (parameterIndex, reader, length); 713 else 714 throw new java.lang.UnsupportedOperationException ("Method setCharacterStream() not yet implemented."); 715 } 716 717 public void setRef (int parameterIndex, Ref x) throws SQLException  718 { 719 if (m_pstmt != null) 720 m_pstmt.setRef (parameterIndex, x); 721 else 722 m_vo.setParameter(parameterIndex, x); 723 } 724 725 public void setBlob (int parameterIndex, Blob x) throws SQLException  726 { 727 if (m_pstmt != null) 728 m_pstmt.setObject (parameterIndex, x); 729 else 730 m_vo.setParameter(parameterIndex, x); 731 } 732 733 public void setClob (int parameterIndex, Clob x) throws SQLException  734 { 735 if (m_pstmt != null) 736 m_pstmt.setObject (parameterIndex, x); 737 else 738 m_vo.setParameter(parameterIndex, x); 739 } 740 741 public void setArray (int parameterIndex, Array x) throws SQLException  742 { 743 if (m_pstmt != null) 744 m_pstmt.setObject (parameterIndex, x); 745 else 746 m_vo.setParameter(parameterIndex, x); 747 } 748 749 public void setDate (int parameterIndex, Date x, Calendar cal) throws SQLException  750 { 751 if (m_pstmt != null) 752 m_pstmt.setDate (parameterIndex, x, cal); 753 else 754 throw new java.lang.UnsupportedOperationException ("Method setDate() not yet implemented."); 755 } 756 757 public void setTime (int parameterIndex, Time x, Calendar cal) throws SQLException  758 { 759 if (m_pstmt != null) 760 m_pstmt.setTime (parameterIndex, x, cal); 761 else 762 throw new java.lang.UnsupportedOperationException ("Method setTime() not yet implemented."); 763 } 764 765 public void setTimestamp (int parameterIndex, Timestamp x, Calendar cal) throws SQLException  766 { 767 if (m_pstmt != null) 768 m_pstmt.setTimestamp (parameterIndex, x, cal); 769 else 770 throw new java.lang.UnsupportedOperationException ("Method setTimestamp() not yet implemented."); 771 } 772 773 public void setURL (int parameterIndex, URL x) throws SQLException  774 { 775 if (m_pstmt != null) 776 m_pstmt.setObject (parameterIndex, x); 777 else 778 m_vo.setParameter(parameterIndex, x); 779 } 780 781 792 793 797 public String toString() 798 { 799 if (m_pstmt != null) 800 return "CompiereStatement[Local=" + m_pstmt + "]"; 801 return "CompiereStatement[" + m_vo + "]"; 802 } 804 805 806 811 private PreparedStatement local_getPreparedStatement() 812 { 813 Connection conn = local_getConnection(); 815 PreparedStatement pstmt = null; 816 try 817 { 818 pstmt = conn.prepareStatement(m_vo.getSql(), m_vo.getResultSetType(), m_vo.getResultSetConcurrency()); 819 ArrayList parameters = m_vo.getParameters(); 821 for (int i = 0; i < parameters.size(); i++) 822 { 823 Object o = parameters.get(i); 824 if (o == null) 825 throw new java.lang.NullPointerException ("local_getPreparedStatement Null Parameter #" + i); 826 else if (o instanceof NullParameter) 827 { 828 int type = ((NullParameter)o).getType(); 829 pstmt.setNull(i+1, type); 830 } 831 else if (o instanceof Integer ) 832 pstmt.setInt(i+1, ((Integer )o).intValue()); 833 else if (o instanceof String ) 834 pstmt.setString(i+1, (String )o); 835 else if (o instanceof Timestamp ) 836 pstmt.setTimestamp(i+1, (Timestamp )o); 837 else if (o instanceof BigDecimal ) 838 pstmt.setBigDecimal(i+1, (BigDecimal )o); 839 else 840 throw new java.lang.UnsupportedOperationException ("local_getPreparedStatement unknown Parameter Class=" + o.getClass()); 841 } 842 } 843 catch (SQLException ex) 844 { 845 log.error("local_getPreparedStatement", ex); 846 try 847 { 848 if (pstmt != null) 849 pstmt.close(); 850 pstmt = null; 851 } 852 catch (SQLException ex1) 853 { 854 } 855 } 856 return pstmt; 857 } 859 863 private Connection local_getConnection() 864 { 865 Connection conn = null; 866 if (m_vo.getResultSetConcurrency () == ResultSet.CONCUR_UPDATABLE) 867 conn = DB.getConnectionRW (); 868 else 869 conn = DB.getConnectionRO (); 870 return conn; 871 } 873 874 875 879 public RowSet remote_getRowSet() 880 { 881 try 883 { 884 CompiereDatabase db = CConnection.get().getDatabase(); 885 if (db == null) 886 throw new NullPointerException ("CompiereStatement.remote_getRowSet - no Database"); 887 PreparedStatement pstmt = local_getPreparedStatement(); 889 ResultSet rs = pstmt.executeQuery(); 890 RowSet rowSet = db.getRowSet (rs); 891 rs.close(); 892 pstmt.close(); 893 if (rowSet == null) 895 throw new NullPointerException ("CompiereStatement.remore_getRowSet - no RowSet"); 896 return rowSet; 897 } 898 catch (Exception ex) 899 { 900 log.error("remote_getRowSet - " + m_vo, ex); 901 throw new RuntimeException (ex); 902 } 903 } 905 909 public int remote_executeUpdate() 910 { 911 log.debug("remote_executeUpdate"); 912 try 913 { 914 CompiereDatabase db = CConnection.get().getDatabase(); 915 if (db == null) 916 throw new NullPointerException ("CompiereStatement.remote_executeUpdate - no Database"); 917 PreparedStatement pstmt = local_getPreparedStatement(); 919 int result = pstmt.executeUpdate(); 920 pstmt.close(); 921 return result; 923 } 924 catch (Exception ex) 925 { 926 log.error("remote_executeUpdate - " + m_vo, ex); 927 throw new RuntimeException (ex); 928 } 929 } 931 } 933
| Popular Tags
|