Project

General

Profile

« Previous | Next » 

Revision 1141

Added by Jing Tao over 22 years ago

Change back to Connection. DBConnection will store in a cvs branch.

View differences:

src/edu/ucsb/nceas/metacat/DBEntityResolver.java
52 52
 */
53 53
public class DBEntityResolver implements EntityResolver
54 54
{
55
  //private Connection conn = null;
55
  private Connection conn = null;
56 56
  private DefaultHandler handler = null;
57 57
  private String docname = null;
58 58
  private String doctype = null;
......
64 64
   *
65 65
   * @param conn the JDBC connection to which information is written
66 66
   */
67
  public DBEntityResolver()
67
  public DBEntityResolver(Connection conn)
68 68
  {
69
    //this.conn = conn;
69
    this.conn = conn;
70 70
  }
71 71
  /** 
72 72
   * Construct an instance of the DBEntityResolver class
......
75 75
   * @param handler the SAX handler to determine parsing context
76 76
   * @param dtd Reader of new dtd to be uploaded on server's file system
77 77
   */
78
  public DBEntityResolver(DefaultHandler handler, Reader dtd)
78
  public DBEntityResolver(Connection conn, DefaultHandler handler, Reader dtd)
79 79
  {
80
    //this.conn = conn;
80
    this.conn = conn;
81 81
    this.handler = handler;
82 82
    this.dtdtext = dtd;
83 83
  }
......
185 185
                 throws SAXException
186 186
  {
187 187
    String systemid = null;
188
    Statement stmt = null;
189
    DBConnection conn = null;
190
    int serialNumber = -1;
188
    Statement stmt;
191 189
    try {
192
      //check out DBConnection
193
      conn=DBConnectionPool.getDBConnection("DBEntityResolver.getDTDSystemID");
194
      serialNumber=conn.getCheckOutSerialNumber();
195
      
196 190
      stmt = conn.createStatement();
197 191
      stmt.execute("SELECT system_id FROM xml_catalog " + 
198 192
                   "WHERE entry_type = 'DTD' AND public_id = '" +
......
207 201
      throw new SAXException
208 202
      ("DBEntityResolver.getDTDSystemID(): " + e.getMessage());
209 203
    }
210
    finally
211
    {
212
      DBConnectionPool.returnDBConnection(conn, serialNumber);
213
    }//finally
214 204

  
215 205
    // return the selected System ID
216 206
    return systemid;
......
223 213
  private void registerDTD ( String doctype, String systemId )
224 214
                 throws SAXException
225 215
  {
226
    DBConnection conn = null;
227
    int serialNumber = -1;
228 216
    // make a reference in db catalog table with @systemId for @doctype
229 217
    try {
230
      //check out DBConnection
231
      conn=DBConnectionPool.getDBConnection("DBEntityResolver.registerDTD");
232
      serialNumber=conn.getCheckOutSerialNumber();
233
      
234 218
      PreparedStatement pstmt;
235 219
      pstmt = conn.prepareStatement(
236 220
             "INSERT INTO xml_catalog " +
......
246 230
      throw new SAXException
247 231
      ("DBEntityResolver.registerDTD(): " + e.getMessage());
248 232
    }
249
    finally
250
    {
251
      DBConnectionPool.returnDBConnection(conn, serialNumber);
252
    }
253 233
  }
254 234

  
255 235
  /** 

Also available in: Unified diff