1 package de.webman.acl.db.queries; 2 3 import java.sql.Connection ; 4 import java.sql.Types ; 5 import java.sql.SQLException ; 6 import java.sql.ResultSet ; 7 import com.teamkonzept.db.*; 8 import com.teamkonzept.webman.mainint.db.queries.accesscontrol.*; 9 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 10 11 18 public class EventInsert 19 extends TKExtendedPrepQuery 20 { 21 22 24 public static final String [] ORDER = 25 { 26 "NAME" 27 }; 28 29 public static final Object [][] TYPES = 30 { 31 {"NAME", new Integer (Types.VARCHAR)} 32 }; 33 34 public static final boolean[] RELEVANTS = 35 { 36 true 37 }; 38 39 44 45 public static final String SQL = null; 46 47 protected static Class [] queryClasses = { SelectIDWMEvent.class, InsertWMEvent.class, SelectWMEvent.class }; 48 49 51 public boolean execute() { 52 try { 53 init(queryClasses); 54 55 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 56 if (isNotOpen) { 57 aTKDBConnection.beginTransaction(); 58 } 59 60 queries[0].execute(); ResultSet rs = queries[0].fetchResultSet(); 62 Integer wmEventId = null; 63 if (rs != null && rs.next()) { 64 int max = 1; 65 max = rs.getInt(1) + 1; wmEventId = new Integer (max); 67 } 68 69 queries[1].setQueryParams("WM_EVENT_ID", wmEventId); 70 queries[1].setQueryParams("NAME", queryParams.get("NAME")); 71 queries[1].execute(); 73 queries[2].setQueryParams("WM_EVENT_ID", wmEventId); 74 queries[2].execute(); 75 addResult(queries[2].fetchResultSet()); 77 if (isNotOpen) { 78 aTKDBConnection.commitTransaction(); 79 } 80 81 } 82 catch (SQLException sqle) { 83 WebmanExceptionHandler.getException(sqle); 84 try { 85 aTKDBConnection.rollbackTransaction(); 86 } 87 catch (SQLException sqle2) { 88 WebmanExceptionHandler.getException(sqle2); 89 } 90 } 91 finally { 92 return hasResults(); 93 } 94 } 95 96 public void initQuery (Connection connection) 97 { 98 super.initQuery(connection, 99 true, 100 ORDER, 101 TYPES, 102 RELEVANTS, 103 SQL); 104 } 105 106 } 107 | Popular Tags |