Changeset 873e52de84747c990bb3a932eb6e9d93db3063f8
- Timestamp:
- 06/09/07 18:54:43
(1 year ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1181408083 +0200
- git-parent:
[9db63defa4c6f093cf3eca25f2877d4daa834bb7]
- git-author:
- Christopher Jung <bktheg@web.de> 1181408083 +0200
- Message:
Transaktionsunterstuetzung aus der DB-Klasse entfernt (da jetzt von Hibernate verwaltet)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r948cef9 |
r873e52d |
|
| 26 | 26 | import java.sql.Statement; |
|---|
| 27 | 27 | |
|---|
| 28 | | import net.driftingsouls.ds2.server.framework.Common; |
|---|
| 29 | 28 | import net.driftingsouls.ds2.server.framework.Loggable; |
|---|
| 30 | 29 | |
|---|
| … | … | |
| 40 | 39 | private int affectedRows = 0; |
|---|
| 41 | 40 | private int insertid = -1; |
|---|
| 42 | | private boolean tStatus = false; |
|---|
| 43 | 41 | private boolean transaction = false; |
|---|
| 44 | 42 | private boolean debugTransaction; |
|---|
| … | … | |
| 287 | 285 | */ |
|---|
| 288 | 286 | public void tBegin(boolean debugtransact) { |
|---|
| 289 | | if( !transaction ) { |
|---|
| 290 | | transaction = true; |
|---|
| 291 | | tStatus = true; |
|---|
| 292 | | debugTransaction = debugtransact; |
|---|
| 293 | | |
|---|
| 294 | | |
|---|
| 295 | | try { |
|---|
| 296 | | connection.setAutoCommit(false); |
|---|
| 297 | | } |
|---|
| 298 | | catch( SQLException e ) { |
|---|
| 299 | | e.printStackTrace(); |
|---|
| 300 | | throw new SQLRuntimeException(e); |
|---|
| 301 | | } |
|---|
| 302 | | } |
|---|
| | 287 | // EMPTY |
|---|
| 303 | 288 | } |
|---|
| 304 | 289 | |
|---|
| … | … | |
| 315 | 300 | */ |
|---|
| 316 | 301 | public void tUpdate( int count, Object ... query ) { |
|---|
| 317 | | if( !transaction || tStatus ) { |
|---|
| 318 | | update(query); |
|---|
| 319 | | if( transaction && (affectedRows() != count) ) { |
|---|
| 320 | | tStatus = false; |
|---|
| 321 | | if( debugTransaction ) { |
|---|
| 322 | | LOG.warn("Transaktion fehlgeschlagen: "+Common.implode("", query)); |
|---|
| 323 | | } |
|---|
| 324 | | } |
|---|
| 325 | | } |
|---|
| 326 | | } |
|---|
| 327 | | |
|---|
| 328 | | /** |
|---|
| 329 | | * Fuehrt ein Rollback auf der aktuellen Transaktion aus |
|---|
| 330 | | * |
|---|
| 331 | | */ |
|---|
| 332 | | public void tRollback() { |
|---|
| 333 | | try { |
|---|
| 334 | | connection.rollback(); |
|---|
| 335 | | connection.setAutoCommit(true); |
|---|
| 336 | | } |
|---|
| 337 | | catch( SQLException e ) { |
|---|
| 338 | | e.printStackTrace(); |
|---|
| 339 | | throw new SQLRuntimeException(e); |
|---|
| 340 | | } |
|---|
| 341 | | transaction = false; |
|---|
| | 302 | update(query); |
|---|
| 342 | 303 | } |
|---|
| 343 | 304 | |
|---|
| … | … | |
| 349 | 310 | */ |
|---|
| 350 | 311 | public boolean tCommit() { |
|---|
| 351 | | if( tStatus == true ) { |
|---|
| 352 | | try { |
|---|
| 353 | | connection.commit(); |
|---|
| 354 | | connection.setAutoCommit(true); |
|---|
| 355 | | } |
|---|
| 356 | | catch( SQLException e ) { |
|---|
| 357 | | e.printStackTrace(); |
|---|
| 358 | | throw new SQLRuntimeException(e); |
|---|
| 359 | | } |
|---|
| 360 | | } |
|---|
| 361 | | else { |
|---|
| 362 | | tRollback(); |
|---|
| 363 | | } |
|---|
| 364 | | |
|---|
| 365 | | transaction = false; |
|---|
| 366 | | |
|---|
| 367 | | return tStatus; |
|---|
| 368 | | } |
|---|
| 369 | | |
|---|
| 370 | | /** |
|---|
| 371 | | * Liefert die Status der letzten Transaktion zurueck. |
|---|
| 372 | | * |
|---|
| 373 | | * @return true, falls der Status der letzten Transaktion "ok" war/ist |
|---|
| 374 | | */ |
|---|
| 375 | | public boolean tStatus() { |
|---|
| 376 | | return tStatus; |
|---|
| 377 | | } |
|---|
| 378 | | |
|---|
| 379 | | protected void setTStatus(boolean status) { |
|---|
| 380 | | tStatus = status; |
|---|
| | 312 | return true; |
|---|
| 381 | 313 | } |
|---|
| 382 | 314 | |
|---|
| … | … | |
| 436 | 368 | protected void error( String text, Statement stmt ) { |
|---|
| 437 | 369 | error = true; |
|---|
| 438 | | tStatus = false; |
|---|
| 439 | 370 | LOG.error(text); |
|---|
| 440 | 371 | try { |
|---|
| r283e6c7 |
r873e52d |
|
| 24 | 24 | import java.sql.SQLException; |
|---|
| 25 | 25 | |
|---|
| 26 | | import net.driftingsouls.ds2.server.framework.Common; |
|---|
| 27 | 26 | import net.driftingsouls.ds2.server.framework.Loggable; |
|---|
| 28 | 27 | |
|---|
| … | … | |
| 102 | 101 | */ |
|---|
| 103 | 102 | public void tUpdate( int count, Object ... values ) { |
|---|
| 104 | | if( !db.isTransaction() || db.tStatus() ) { |
|---|
| 105 | | update(values); |
|---|
| 106 | | if( db.isTransaction() && (affectedRows() != count) ) { |
|---|
| 107 | | db.setTStatus(false); |
|---|
| 108 | | if( db.isDebugTransaction() ) { |
|---|
| 109 | | LOG.warn("Transaktion (PreparedStatement) fehlgeschlagen: "+query+"\nValues: "+Common.implode(" ;; ", values)); |
|---|
| 110 | | } |
|---|
| 111 | | } |
|---|
| 112 | | } |
|---|
| | 103 | update(values); |
|---|
| 113 | 104 | } |
|---|
| 114 | 105 | |
|---|
| r6d5ded6 |
r873e52d |
|
| 550 | 550 | "User: "+(getContext().getActiveUser() != null ? getContext().getActiveUser().getID() : "none")+"\n" + |
|---|
| 551 | 551 | "Query-String: "+getContext().getRequest().getQueryString()); |
|---|
| 552 | | if( getDatabase().isTransaction() ) { |
|---|
| 553 | | getDatabase().tRollback(); |
|---|
| 554 | | } |
|---|
| 555 | 552 | } |
|---|
| 556 | 553 | catch( NoSuchMethodException e ) { |
|---|
| … | … | |
| 564 | 561 | "User: "+(getContext().getActiveUser() != null ? getContext().getActiveUser().getID() : "none")+"\n" + |
|---|
| 565 | 562 | "Query-String: "+getContext().getRequest().getQueryString()); |
|---|
| 566 | | if( getDatabase().isTransaction() ) { |
|---|
| 567 | | getDatabase().tRollback(); |
|---|
| 568 | | } |
|---|
| 569 | 563 | getContext().getDB().getTransaction().rollback(); |
|---|
| 570 | 564 | } |
|---|
| r283e6c7 |
r873e52d |
|
| 110 | 110 | echo.append(Common.tableEnd()); |
|---|
| 111 | 111 | |
|---|
| 112 | | db.tRollback(); |
|---|
| 113 | | |
|---|
| 114 | | return; |
|---|
| | 112 | context.getDB().getTransaction().rollback(); |
|---|
| 115 | 113 | } |
|---|
| 116 | 114 | } |
|---|
| r9db63de |
r873e52d |
|
| 58 | 58 | <mapping class="net.driftingsouls.ds2.server.ships.Ship" /> |
|---|
| 59 | 59 | <mapping class="net.driftingsouls.ds2.server.ships.ShipBaubar" /> |
|---|
| 60 | | <!-- ships_lost --> |
|---|
| | 60 | <mapping class="net.driftingsouls.ds2.server.ships.ShipLost" /> |
|---|
| 61 | 61 | <mapping class="net.driftingsouls.ds2.server.ships.ShipModules" /> |
|---|
| 62 | 62 | <!-- skn --> |
|---|