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