- 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/metadata/METSDescriptive.java
r8742 r9874 8 8 9 9 import java.sql.SQLException; 10 import java.sql.Statement; 10 11 import java.sql.ResultSet; 11 12 … … 275 276 } else { 276 277 // TODO: raise an error! 277 System.out.println("Error: METSDescri iptive: unrecognised tag "+childName);278 System.out.println("Error: METSDescriptive: unrecognised tag "+childName); 278 279 } 279 280 } … … 375 376 select.setWhere(where); 376 377 377 connection.execute(select.toString());378 379 378 try { 379 Statement statement = connection.createStatement(); 380 ResultSet resultSet = statement.executeQuery(select.toString()); 380 381 GS3SQLAction action; 381 382 382 ResultSet resultSet = connection.getResultSet(); 383 384 if (resultSet != null && 385 resultSet.first()) { 383 if (resultSet.first()) { 386 384 // the node already exists - no need to do anything as such 387 385 GS3SQLUpdate update = new GS3SQLUpdate("metadata"); … … 389 387 action = update; 390 388 } 391 else 392 { // Set result set to null, just in case next() didn't work above... 393 resultSet = null; 394 395 // It is a new node and needs writing 396 action = new GS3SQLInsert("metadata"); 397 398 action.addValue("DocID", document.getID().toString()); 399 action.addValue("MetaID", this.ID); 400 } 389 else { // Set result set to null, just in case first() didn't work above... 390 // It is a new node and needs writing 391 action = new GS3SQLInsert("metadata"); 392 393 action.addValue("DocID", document.getID().toString()); 394 action.addValue("MetaID", this.ID); 395 } 401 396 402 397 // always set the group identifier … … 404 399 405 400 // execute the action as required 406 connection.execute(action.toString()); 407 408 // create a new resultset if necessary 409 if (resultSet == null) { 410 // now execute the select statement again to get the new identifier 411 // 'MetadataRef' 412 // System.out.println(select.toString()); 413 connection.execute(select.toString()); 414 415 resultSet = connection.getResultSet(); 416 resultSet.first(); 417 } 418 419 // get the reference for this item... 420 sqlId = resultSet.getInt("MetadataRef"); 401 statement.execute(action.toString()); 402 403 // get the resultSet again 404 // now execute the select statement again to get the new identifier 405 // 'MetadataRef' 406 // System.out.println(select.toString()); 407 resultSet = statement.executeQuery(select.toString()); 408 409 if (resultSet.first()) { 410 // get the reference for this item... 411 sqlId = resultSet.getInt("MetadataRef"); 412 } 413 statement.close(); 421 414 } 422 415 catch (SQLException sql){ 423 System.out.println(sql); 416 System.err.println("METSDescriptive.writeSQL(): "+sql); 417 } 418 if (sqlId == -1) { 419 return false; 424 420 } 425 421 … … 471 467 select.setWhere(where); 472 468 473 connection.execute(select.toString()); 474 475 // parse through the namespaces, calling the namespace class to create instances 476 // as it will 477 ResultSet namespaceSet = connection.getResultSet(); 478 if (namespaceSet != null && namespaceSet.first()) { 469 Statement statement = connection.createStatement(); 470 ResultSet namespaceSet = statement.executeQuery(select.toString()); 471 472 // parse through the namespaces, calling the namespace class to create instances as it will 473 if (namespaceSet.first()) { 479 474 do { 480 475 METSNamespace namespace = METSNamespace.readSQL(connection, namespaceSet); … … 483 478 } 484 479 else { 485 System. out.println("Null namespace output");480 System.err.println("Null namespace output"); 486 481 } 487 482 } 488 483 while (namespaceSet.next()); 489 484 } 490 485 statement.close(); 491 486 return descriptive; 492 487 } 493 488 catch (SQLException sqlEx){ 494 System. out.println(sqlEx);489 System.err.println("METSDescriptive.readSQL(): "+sqlEx); 495 490 System.exit(1); 496 491 }
Note:
See TracChangeset
for help on using the changeset viewer.