1 5 package com.teamkonzept.webman.mainint.db.queries; 6 7 import java.sql.*; 8 9 import com.teamkonzept.db.*; 10 import com.teamkonzept.webman.mainint.db.queries.template.*; 11 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 12 13 19 public class TKDBTmplNew extends TKExtendedPrepQuery 20 { 21 22 public final static boolean isPrepared = true; 23 24 public final static String [] order = { "TEMPLATE_NAME" }; 25 26 public final static Object [][] types = 27 { {"TEMPLATE_NAME", new Integer (Types.VARCHAR)} }; 28 29 public final static boolean[] setRelevants = { true }; 30 31 54 55 protected static Class [] queryClasses = { 56 SelectMaxTemplate.class, 57 InsertTemplate.class, 58 SelectTemplate.class 59 }; 60 61 public boolean execute() 62 { 63 try 64 { 65 init(queryClasses); 66 67 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 68 if (isNotOpen) 69 { 70 TKDBManager.beginTransaction(); 71 } 72 73 queries[0].execute(); ResultSet rs = queries[0].fetchResultSet(); 75 int max = 1; 76 if (rs != null && rs.next()) 77 { 78 max = rs.getInt(1) + 1; 79 } 80 81 queries[1].setQueryParams("TEMPLATE_ID", new Integer (max)); 82 queries[1].setQueryParams("TEMPLATE_NAME", 83 queryParams.get("TEMPLATE_NAME")); 84 queries[1].execute(); 86 queries[2].setQueryParams("TEMPLATE_ID", new Integer (max)); 87 queries[2].execute(); addResult(queries[2].fetchResultSet()); 89 90 if (isNotOpen) 91 { 92 TKDBManager.commitTransaction(); 93 } 94 } 95 catch(Throwable t) 96 { 97 TKDBManager.safeRollbackTransaction(t); 98 } 99 return hasResults(); 100 } 101 102 103 public void initQuery(Connection con) 104 { 105 super.initQuery(con, isPrepared, order, types, setRelevants, null); 106 } 107 } 108 | Popular Tags |