Project

General

Profile

« Previous | Next » 

Revision 513

Added by bojilova about 24 years ago

bug fix about util.openDBConnection() for xmlIndex tread

View differences:

src/edu/ucsb/nceas/metacat/DBSAXHandler.java
177 177
  public void run () {
178 178
    DBSAXNode currNode = null;
179 179
    DBSAXNode prevNode = null;
180
    Connection dbconn = null;
180 181
    int step = 0;
181 182
    int counter = 0;
182 183

  
183 184
    try {
184 185
      // Opening separate db connection for writing XML Index
185 186
      MetaCatUtil util = new MetaCatUtil();
186
      Connection conn = util.getConnection();
187
      conn.setAutoCommit(false);
187
      dbconn = util.openDBConnection();
188
      dbconn.setAutoCommit(false);
188 189

  
189 190
      // Going through the elements of the document and writing its Index
190 191
      Enumeration nodes = nodeIndex.elements();
191 192
      while ( nodes.hasMoreElements() ) {
192 193
        currNode = (DBSAXNode)nodes.nextElement();
193
        currNode.updateNodeIndex(conn, docid, currentDocument.getDoctype());
194
        currNode.updateNodeIndex(dbconn, docid, currentDocument.getDoctype());
194 195
      }
195 196
    
196
      conn.commit();
197
      dbconn.commit();
197 198
      
198 199
      //if this is a package file then write the package info to 
199 200
      //the xml_relation table. relationHandler checks to see
200 201
      //if it is a package file so you don't have to do it here.
201
      DocumentImpl xmldoc = new DocumentImpl(conn, docid);
202
      relationHandler rth = new relationHandler(xmldoc, conn);
202
      DocumentImpl xmldoc = new DocumentImpl(dbconn, docid);
203
      relationHandler rth = new relationHandler(xmldoc, dbconn);
203 204
      
204
      util.returnConnection(conn);
205
      conn.close();
206
      //util.closeConnections();
205
      dbconn.close();
207 206

  
208 207
    } catch (Exception e) {
209 208
      try {
210
        conn.rollback();
211
        conn.close();
209
        dbconn.rollback();
210
        dbconn.close();
212 211
      } catch (SQLException sqle) {}
213 212
      System.out.println("Error writing XML Index. " + e.getMessage()); 
214 213
    }      

Also available in: Unified diff