Project

General

Profile

« Previous | Next » 

Revision 1217

Added by Jing Tao almost 22 years ago

Merge DBConnection branch to head.

View differences:

DBTransform.java
73 73
 */
74 74
public class DBTransform {
75 75

  
76
  private Connection	conn = null;
76
  //private Connection	conn = null;
77 77
  private MetaCatUtil   util = null;
78 78
  private String 	configDir = null;
79 79
  private String	defaultStyle = null;
......
85 85
   *
86 86
   * @param conn the database connection from which to lookup the public ids
87 87
   */
88
  public DBTransform( Connection conn ) 
88
  public DBTransform() 
89 89
                  throws IOException, 
90 90
                         SQLException, 
91 91
                         ClassNotFoundException
92 92
  {
93
    this.conn = conn;
93
    //this.conn = conn;
94 94
    util = new MetaCatUtil();
95 95
    configDir = util.getOption("config-dir");
96 96
    defaultStyle = util.getOption("default-style");
......
318 318
                String targettype) {
319 319

  
320 320
    // Look up the System ID of a particular object
321
    PreparedStatement pstmt;
321
    PreparedStatement pstmt = null;
322 322
    String the_system_id = null;
323
    DBConnection dbConn = null;
324
    int serialNumber = -1;
323 325
    try {
326
      dbConn=DBConnectionPool.
327
                  getDBConnection("DBTransform.getSystemId");
328
      serialNumber=dbConn.getCheckOutSerialNumber();
324 329
      pstmt =
325
        conn.prepareStatement("SELECT system_id " +
330
        dbConn.prepareStatement("SELECT system_id " +
326 331
                "FROM xml_catalog " +
327 332
                "WHERE entry_type = ? " +
328 333
                "AND source_doctype = ? " +
......
363 368
      return ("Error getting id in DBTransform.getSystemId:: " + 
364 369
               e.getMessage());
365 370
    }
371
    finally
372
    {
373
      try
374
      {
375
        pstmt.close();
376
      }//try
377
      catch (SQLException sqlE)
378
      {
379
        MetaCatUtil.debugMessage("Error in DBTransform.getSystemId: "
380
                                   +sqlE.getMessage(), 30);
381
      }//catch
382
      finally
383
      {
384
        DBConnectionPool.returnDBConnection(dbConn, serialNumber);
385
      }//finally
386
    }//finally
366 387
    return the_system_id;
367 388
  }
368 389

  
......
382 403
        try {
383 404
                    
384 405
          // Open a connection to the database
385
          MetaCatUtil   util = new MetaCatUtil();
386
          Connection dbconn = util.openDBConnection();
406
          /*MetaCatUtil   util = new MetaCatUtil();
407
          Connection dbconn = util.openDBConnection();*/
387 408

  
388 409
          // Create a test document
389 410
          StringBuffer testdoc = new StringBuffer();
......
393 414
          testdoc.append("<title>My test doc</title></eml-dataset>");
394 415

  
395 416
          // Transform the document to the new doctype
396
          DBTransform dbt = new DBTransform(dbconn);
417
          DBTransform dbt = new DBTransform();
397 418
          dbt.transformXMLDocument(testdoc.toString(), 
398 419
                                   "-//NCEAS//eml-dataset//EN", 
399 420
                                   "-//W3C//HTML//EN", 

Also available in: Unified diff