1 package de.webman.content.db.queries; 2 3 import java.sql.Connection ; 4 import java.sql.Types ; 5 import java.sql.SQLException ; 6 import com.teamkonzept.db.TKDBManager; 7 import com.teamkonzept.db.TKExtendedPrepQuery; 8 import com.teamkonzept.webman.mainint.db.queries.content.SelectContent; 9 import de.webman.content.db.ContentConstants; 10 11 46 public class XMLContentUpdate 47 extends TKExtendedPrepQuery 48 { 49 51 53 56 private final static boolean IS_PREPARED = true; 57 58 61 private final static String [] PARAMETER_ORDER = 62 { 63 ContentConstants.XML_TEXT, 64 ContentConstants.CONTENT_ID 65 }; 66 67 70 private final static Object [][] PARAMETER_TYPES = 71 { 72 {ContentConstants.XML_TEXT, new Integer (Types.CLOB)}, 73 {ContentConstants.CONTENT_ID, new Integer (Types.INTEGER)} 74 }; 75 76 79 private final static boolean[] SET_RELEVANTS = 80 { 81 true 82 }; 83 84 87 private static Class [] QUERY_CLASSES = 88 { 89 UpdateContent.class, 90 SelectContent.class 91 }; 92 93 94 96 104 public final boolean execute () 105 throws SQLException 106 { 107 try 108 { 109 init(QUERY_CLASSES); 111 112 boolean transactional = aTKDBConnection.isAutoCommit(); 114 115 if (transactional) 116 { 117 TKDBManager.beginTransaction(); 119 } 120 121 this.queries[0].setQueryParams(ContentConstants.XML_TEXT, queryParams.get(ContentConstants.XML_TEXT)); 123 this.queries[0].setQueryParams(ContentConstants.CONTENT_ID, queryParams.get(ContentConstants.CONTENT_ID)); 124 this.queries[0].execute(); 125 126 this.queries[1].setQueryParams(ContentConstants.CONTENT_ID, queryParams.get(ContentConstants.CONTENT_ID)); 128 this.queries[1].execute(); 129 130 addResult(this.queries[1].fetchResultSet()); 132 133 if (transactional) 134 { 135 TKDBManager.commitTransaction(); 137 } 138 } 139 catch (Throwable t) 140 { 141 TKDBManager.safeRollbackTransaction(t); 142 } 143 144 return hasResults(); 146 } 147 148 153 public void initQuery (Connection connection) 154 { 155 super.initQuery(connection, 156 IS_PREPARED, 157 PARAMETER_ORDER, 158 PARAMETER_TYPES, 159 SET_RELEVANTS, 160 this.sqlString); 161 } 162 163 } 164 | Popular Tags |