Project

General

Profile

« Previous | Next » 

Revision 601

Added by berkley about 24 years ago

changed connection handling in the constructor

View differences:

src/edu/ucsb/nceas/metacat/RelationHandler.java
33 33
   */
34 34
  public RelationHandler(DocumentImpl xmldoc, Connection conn)
35 35
  {
36
    this.conn = conn;    
36
    //this.conn = conn;
37
    try
38
    {
39
      this.conn = util.openDBConnection();
40
    }
41
    catch(Exception e)
42
    {
43
      System.out.println("error opening connection in relationHandler");
44
    }
45
    
37 46
    this.xmldoc = xmldoc;
38 47
    if(xmldoc.getDoctype().equals(util.getOption("packagedoctype")))
39 48
    { //make sure this doctype is a package document then run the thread
......
105 114
            insertTransRelation.append(subject).append("', '");
106 115
            insertTransRelation.append(subjectDoctype).append("')");
107 116
            pstmt = conn.prepareStatement(insertTransRelation.toString());
108
            pstmt.execute();
117
            pstmt.execute(); 
109 118
            
110 119
            insertTransRelation = new StringBuffer();
111 120
            //put the same relation in with the subject and object switched
......
156 165
      }
157 166
      
158 167
      conn.commit();
168
      conn.close();
159 169
      btThread = null;
160 170

  
161
    } catch(Exception e) { 
162
      try { 
171
    } 
172
    catch(Exception e) 
173
    { 
174
      try 
175
      { 
163 176
        conn.rollback();
164
      } catch (SQLException sqle) {}
177
      } 
178
      catch (SQLException sqle) {}
165 179
      System.out.println("Error in relationHandler: " + e.getMessage());
166 180
      util.debugMessage("Error in relationHandler: " + e.getMessage());
167 181
      e.printStackTrace(System.out);

Also available in: Unified diff