[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/utils DB.java,1.8,1.9
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2002-09-09 21:27:47
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/utils In directory usw-pr-cvs1:/tmp/cvs-serv10950/src/net/sourceforge/idrs/utils Modified Files: DB.java Log Message: added transaction support and new form handling Index: DB.java =================================================================== RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/utils/DB.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DB.java 22 Aug 2002 20:06:37 -0000 1.8 --- DB.java 9 Sep 2002 21:27:44 -0000 1.9 *************** *** 16,19 **** --- 16,20 ---- import java.text.*; import net.sourceforge.idrs.script.IDRSScript; + import net.sourceforge.idrs.core.report.IDRSHead; import java.io.*; /** *************** *** 38,41 **** --- 39,46 ---- public static final int PROC = 1; public static final int SQL = 2; + + public static final int TRANS_BEGIN = 0; + public static final int TRANS_COMPLETE = 1; + protected int cursurLocation, beginWith = 0; *************** *** 61,64 **** --- 66,72 ---- protected String methodName; protected int type; + + protected int transactionType; + protected transient boolean hasResults; protected transient Statement holdForClean; *************** *** 718,722 **** } else {//server cursur is default ! if (firstRead) { if (rs.next()) { --- 726,730 ---- } else {//server cursur is default ! if (firstRead) { if (rs.next()) { *************** *** 772,780 **** ! public void buildDB(String[] vars,IDRSScript idrs) throws Exception{ ! System.out.println("In buildDB"); ! System.out.println("cursor : " + (this.cursur == DB.CLIENT)); ! System.out.println("wasCached : " + this.wasCached); ! if (this.cursur != DB.CLIENT && ! this.wasCached) { if (type == METHOD) { --- 780,804 ---- ! public void buildDB(String[] vars,IDRSHead idrs) throws Exception{ ! Exception e = null; ! boolean wasException = false; ! HashMap caches = null; ! ! if (this.cursur == DB.CLIENT) { ! caches = ((HashMap) idrs.getSession().getAttribute("IDRS_DB_CACHE")); ! if (caches == null) { ! caches = new HashMap(); ! idrs.getSession().setAttribute("IDRS_DB_CACHE",caches); ! } ! this.wasCached = (caches.get(this.name) != null); ! } ! ! if (this.transactionType == TRANS_BEGIN || this.transactionType == TRANS_COMPLETE) { ! idrs.addTransaction(name); ! } ! ! ! ! if (! this.wasCached && ! idrs.isError()) { if (type == METHOD) { *************** *** 786,790 **** --- 810,829 ---- ProcSQL(sql,(type == PROC),vars); } + + if (this.cursur == DB.CLIENT) { + caches.put(this.name,rows); + } + } + else { + this.rows = ((LinkedList) ((HashMap) idrs.getSession().getAttribute("IDRS_DB_CACHE")).get(this.name)); } + + if (idrs.isError() || wasException) { + idrs.rollbackAllTransactions(); + if (wasException) throw e; + } + else if (this.transactionType == TRANS_COMPLETE) { + idrs.commitAllTransactions(); + } } *************** *** 846,849 **** --- 885,892 ---- this.wasCached = true; } + + public void setTransactionType(int type) { + this.transactionType = type; + } } |