Changeset 9874 for trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AZListClassifier.java
- Timestamp:
- 2005-05-16T11:02:50+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AZListClassifier.java
r8742 r9874 9 9 import java.sql.ResultSet; 10 10 import java.sql.SQLException; 11 import java.sql.Statement; 11 12 12 13 import org.xml.sax.XMLReader; … … 189 190 select.setWhere(where); 190 191 191 connection.execute(select.toString());192 192 193 193 try { 194 ResultSet results = connection.getResultSet(); 195 if (results != null && results.first()) { 194 Statement statement = connection.createStatement(); 195 ResultSet results = statement.executeQuery(select.toString()); 196 if (results.first()) { 196 197 GS3SQLUpdate update = new GS3SQLUpdate("classifiers"); 197 198 update.setWhere(where); … … 206 207 207 208 action = insert; 209 classifyRef = -1; 208 210 } 209 211 action.addValue("ClassifyID", label); … … 213 215 action.addValue("NumLeafDocs", Integer.toString(noOfLeafDocs), GS3SQLField.INTEGER_TYPE); 214 216 215 connection.execute(action.toString()); 216 classifyRef = -1; 217 } 218 catch (SQLException sqlEx) { 219 System.err.println(sqlEx); 220 return -1; 221 } 222 223 // get the ClassifyRef if we don't already have it (have done a 224 // insert action above)... 225 if (classifyRef == -1) { 226 connection.execute(select.toString()); 227 228 try { 229 ResultSet results = connection.getResultSet(); 230 if (results == null || !results.first()) { 217 // do the update/insert 218 statement.execute(action.toString()); 219 220 221 // get the ClassifyRef if we don't already have it (have done a 222 // insert action above)... 223 if (classifyRef == -1) { 224 results = statement.executeQuery(select.toString()); 225 if (!results.first()) { 231 226 return -1; 232 227 } … … 234 229 classifyRef = results.getInt("ClassifyRef"); 235 230 } 236 catch (SQLException sqlEx) { 237 System.err.println(sqlEx); 231 232 statement.close(); 233 } catch (SQLException sqlEx) { 234 System.err.println("AZListClassifier.writeSQLClassifyNode(): "+sqlEx); 238 235 return -1; 239 240 }236 } 237 241 238 242 239 return classifyRef; … … 274 271 } 275 272 273 try { 274 Statement statement = connection.createStatement(); 275 276 276 List children; 277 277 … … 292 292 Iterator iterator = childDocs.iterator(); 293 293 int childOrder = 1; 294 //St 294 295 while (iterator.hasNext()) { 295 296 AZDocumentItem documentItem = (AZDocumentItem) iterator.next(); … … 301 302 insert.addValue("DocOrder", Integer.toString(childOrder), GS3SQLField.INTEGER_TYPE); 302 303 303 connection.execute(insert.toString());304 statement.execute(insert.toString()); 304 305 305 306 childOrder ++; … … 310 311 } 311 312 313 312 314 /* 313 315 else { … … 318 320 delete.setWhere(where); 319 321 320 connection.execute(delete.toString());322 statement.execute(delete.toString()); 321 323 } 322 324 … … 331 333 } 332 334 */ 335 statement.close(); 336 } catch (SQLException e) { 337 System.err.println("AZListClassifier.writeSQL(): "+e); 338 return false; 339 } 333 340 334 341 return true;
Note:
See TracChangeset
for help on using the changeset viewer.