details:   https://code.openbravo.com/erp/devel/pi/rev/ad966a576648
changeset: 16839:ad966a576648
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Jun 14 09:32:25 2012 +0200
summary:   Related to issue 20739. Added quicker methods to disable/enable 
triggers

diffstat:

 src/org/openbravo/dal/core/TriggerHandler.java |  41 +++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)

diffs (65 lines):

diff -r 59459664e970 -r ad966a576648 
src/org/openbravo/dal/core/TriggerHandler.java
--- a/src/org/openbravo/dal/core/TriggerHandler.java    Wed Jun 13 19:42:12 
2012 +0200
+++ b/src/org/openbravo/dal/core/TriggerHandler.java    Thu Jun 14 09:32:25 
2012 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2012 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,6 +19,10 @@
 
 package org.openbravo.dal.core;
 
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
 import org.apache.log4j.Logger;
 import org.openbravo.base.provider.OBProvider;
 import org.openbravo.base.util.Check;
@@ -74,6 +78,41 @@
     }
   }
 
+  public void disableSql() {
+    Connection con = OBDal.getInstance().getConnection();
+    PreparedStatement ps = null;
+    try {
+      ps = con
+          .prepareStatement("INSERT INTO AD_SESSION_STATUS VALUES (get_uuid(), 
'0', '0', 'Y', now(), '0', now(), '0', 'Y')");
+      ps.executeUpdate();
+    } catch (Exception e) {
+      log.error("Couldn't disable triggers: ", e);
+    } finally {
+      try {
+        ps.close();
+      } catch (SQLException e) {
+      }
+    }
+
+  }
+
+  public void enableSql() {
+    Connection con = OBDal.getInstance().getConnection();
+    PreparedStatement ps = null;
+    try {
+      ps = con.prepareStatement("DELETE FROM AD_SESSION_STATUS");
+      ps.executeUpdate();
+    } catch (Exception e) {
+      log.error("Couldn't enable triggers: ", e);
+    } finally {
+      try {
+        ps.close();
+      } catch (SQLException e) {
+      }
+    }
+
+  }
+
   /**
    * @return true if the database triggers are disabled, false in other cases.
    */

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to