Index: src/edu/ucsb/nceas/metacat/DBSAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 91)
+++ src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 92)
@@ -33,7 +33,7 @@
 {
 
    static int elementNo = 0;
-   private String docname;
+   static String docname;
    private String doctype;
    private String systemid;
    private boolean 	debug 	= false;
@@ -76,9 +76,6 @@
     // here is a bug: dtd.getPublicId() and dtd.getSustemId() return null.
     docname = dtd.getName();
     doctype = dtd.getPublicId();
-    //if (doctype == null) {
-      //doctype = docname;
-    //}
     systemid = dtd.getSystemId();
     System.out.println("DOCNAME: " + docname);
     System.out.println("DOCTYPE: " + doctype);
@@ -92,8 +89,11 @@
    public void endDoctype() throws SAXException
    {
     System.out.println("end of DOCTYPE");
-    if (doctype == null)
+    if (doctype == null) {
         doctype = DBEntityResolver.doctype;
+        //if (doctype == null) 
+        //    doctype = docname;
+    }
    }
 
    /** SAX Handler that is called at the start of each XML element */
@@ -117,8 +117,8 @@
       expName = name.getExpandedName();
       
       elementNo++;
-      if ((elementNo == 1) && (doctype == null))
-        throw new SAXException("No DOCTYPE declaration or PUBLIC ID provided");
+      if (docname == null)
+        throw new SAXException("No DOCTYPE declaration provided");
       // Get a reference to the parent element for the id
       long parent_id;
       int nodeIndex;
@@ -190,9 +190,17 @@
    {
     if (elementNo > 0) {
       DBSAXElement currentElement = (DBSAXElement)elementStack.peek();
-      currentElement.writeCommentToDB(data);
+      int nodeIndex = currentElement.incChildNum();
+      currentElement.writeCommentToDB(data, nodeIndex);
     }
    }
+   public void processingInstruction(String target, String data) throws SAXException
+   {
+    if (elementNo == 0)
+        System.out.println("target:" + target + "\ndata:" + data);
+    else if (elementNo > 0)
+        System.out.println("targetHere:" + target + "\ndata:" + data);
+   }
 
    /** SAX Handler that is called at the end of each XML element */
    public void endElement(NSName name) throws SAXException 
Index: src/edu/ucsb/nceas/metacat/DBEntityResolver.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBEntityResolver.java	(revision 91)
+++ src/edu/ucsb/nceas/metacat/DBEntityResolver.java	(revision 92)
@@ -1,5 +1,5 @@
 /**
- *        Name: DBSAXHandler.java
+ *        Name: DBEntityResolver.java
  *     Purpose: A Class that implements org.xml.sax.EntityResolver interface
  *              for resolving external entities
  *   Copyright: 2000 Regents of the University of California and the
@@ -28,7 +28,7 @@
 {
 
    static String doctype = null;
-   static Connection conn = null;
+   private Connection conn = null;
    private int pIdCounter = 0;
    private long currentElementNo;
 
@@ -51,9 +51,10 @@
    {
      String dbSystemId;
      
+     currentElementNo = DBSAXHandler.elementNo;
+     
      if (publicId != null) {
         pIdCounter += 1;
-        currentElementNo = DBSAXHandler.elementNo;
         System.out.println("from DBEntityResolver: current element is " + DBSAXHandler.elementNo);
         System.out.println("from DBEntityResolver: " + pIdCounter + " " + publicId);
         // look at the db XML Catalog and get dbSystemId by this publicId
@@ -63,33 +64,33 @@
             if (dbSystemId == "")
                 // register publicId in db and use the provided systemId
                 if (systemId != "") {
-                    System.out.println("from DBEntityResolver: " + systemId);
                     new URL(systemId);
-                    registerDTDPublicID (conn, publicId, systemId);
+                    registerDTDPublicID (conn, doctype, publicId, systemId);
                     return null;
                 }
             new URL(dbSystemId);
-            System.out.println("from DBEntityResolver: db System ID: " + dbSystemId);
             return new InputSource(dbSystemId);
         } 
-        else {
+        /*else {
             // look at the db XML Catalog and get dbSystemId by this publicId for a given doctype
             dbSystemId = getEntitySystemID (conn, doctype, publicId);
             if (dbSystemId == "")
                 // register publicId in db for a given doctype and use the provided systemId
                 if (systemId != "") {
-                    System.out.println("from DBEntityResolver: " + systemId);
                     new URL(systemId);
                     registerEntityPublicID (conn, doctype, publicId, systemId);
                     return null;
                 }
             new URL(dbSystemId);
-            System.out.println("from DBEntityResolver: db System ID: " + dbSystemId);
             return new InputSource(dbSystemId);
-        }  
+        }*/  
      }
+     // publicId is null => doctype is null => doctype = docname
      if ( systemId != null) {
-        System.out.println("from DBEntityResolver: " + systemId);
+        if (currentElementNo == 0) {
+            doctype = DBSAXHandler.docname;
+            registerDTDPublicID (conn, doctype, "", systemId);
+        }
         new URL(systemId);
      }
     
@@ -105,8 +106,8 @@
         Statement stmt;
         try {
           stmt = conn.createStatement();
-          stmt.execute("SELECT system_id FROM xml_catalog_entities a, xml_catalog b " + 
-                       "WHERE a.entity_type = 'DTD' AND a.source_doctype = b.doctype AND b.doctype = '" + publicId + "'");
+          stmt.execute("SELECT system_id FROM xml_catalog " + 
+                       "WHERE entity_type = 'DTD' AND source_doctype = '" + publicId + "'");
           try {
             ResultSet rs = stmt.getResultSet();
             try {
@@ -127,6 +128,7 @@
           stmt.close();
         } catch (SQLException e) {
           System.out.println("DBEntityResolver.getDTDSystemID() - Error getting id: " + e.getMessage());
+          System.exit(1);
         }
 
         // return the selected System ID
@@ -134,27 +136,21 @@
    }
 
    /** Register Public ID in db XML Catalog */
-   private void registerDTDPublicID (Connection conn, String publicId, String systemId)
+   private void registerDTDPublicID (Connection conn, String doctype, String publicId, String systemId)
    {
         try {
           conn.setAutoCommit(false);
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog (doctype) VALUES (?)");
+                "INSERT INTO xml_catalog (entity_id, entity_type, source_doctype, public_id, system_id) " +
+                "VALUES (null, 'DTD', ?, ?, ?)");
           // Bind the values to the query
-          pstmt.setString(1, publicId);
+          pstmt.setString(1, doctype);
+          pstmt.setString(2, publicId);
+          pstmt.setString(3, systemId);
           // Do the insertion
           pstmt.execute();
           pstmt.close();
-          pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog_entities (entity_id, entity_type, source_doctype, system_id) " +
-                "VALUES (null, 'DTD', ?, ?)");
-          // Bind the values to the query
-          pstmt.setString(1, publicId);
-          pstmt.setString(2, systemId);
-          // Do the insertion
-          pstmt.execute();
-          pstmt.close();
           conn.commit();
           conn.setAutoCommit(true);
         } catch (SQLException e) {
@@ -170,7 +166,7 @@
         Statement stmt;
         try {
           stmt = conn.createStatement();
-          stmt.execute("SELECT system_id FROM xml_catalog_entities " + 
+          stmt.execute("SELECT system_id FROM xml_catalog " + 
                        "WHERE entity_type = 'ENTITY' AND source_doctype = '" + doctype + "' AND public_id = '" + publicId + "'");
           try {
             ResultSet rs = stmt.getResultSet();
@@ -205,7 +201,7 @@
           conn.setAutoCommit(false);
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog_entities (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
+                "INSERT INTO xml_catalog (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
                 "VALUES (null, null, 'ENTITY', ?, ?, ?)");
           // Bind the values to the query
           pstmt.setString(1, doctype);
Index: src/edu/ucsb/nceas/metacat/DBSAXNode.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 91)
+++ src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 92)
@@ -74,17 +74,18 @@
     }
 
     /** creates SQL code and inserts comment into DB connection */
-    void writeCommentToDB(String data) {
+    void writeCommentToDB(String data, int nodeIndex) {
         try {
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
                 "INSERT INTO xml_nodes (nodeid, nodetype, " +
-                "nodename, parentnodeid, nodedata) VALUES (null, ?, null, ?, ?)");
+                "nodename, parentnodeid, nodedata, nodeindex) VALUES (null, ?, null, ?, ?, ?)");
 
           // Bind the values to the query
           pstmt.setString(1, "COMMENT");
           pstmt.setLong(2, getElementID());
           pstmt.setString(3, data);
+          pstmt.setInt(4, nodeIndex);
           // Do the insertion
           pstmt.execute();
           pstmt.close();
Index: src/edu/ucsb/nceas/metacat/DBSAXElement.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXElement.java	(revision 91)
+++ src/edu/ucsb/nceas/metacat/DBSAXElement.java	(revision 92)
@@ -74,17 +74,18 @@
     }
 
     /** creates SQL code and inserts comment into DB connection */
-    void writeCommentToDB(String data) {
+    void writeCommentToDB(String data, int nodeIndex) {
         try {
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
                 "INSERT INTO xml_nodes (nodeid, nodetype, " +
-                "nodename, parentnodeid, nodedata) VALUES (null, ?, null, ?, ?)");
+                "nodename, parentnodeid, nodedata, nodeindex) VALUES (null, ?, null, ?, ?, ?)");
 
           // Bind the values to the query
           pstmt.setString(1, "COMMENT");
           pstmt.setLong(2, getElementID());
           pstmt.setString(3, data);
+          pstmt.setInt(4, nodeIndex);
           // Do the insertion
           pstmt.execute();
           pstmt.close();
Index: src/edu/ucsb/nceas/metacat/DBDTDHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBDTDHandler.java	(revision 91)
+++ src/edu/ucsb/nceas/metacat/DBDTDHandler.java	(revision 92)
@@ -41,13 +41,13 @@
             throws SAXException
    {
     System.out.println("from DBDTDHandler.notationDecl");
-    System.out.println(name);
-    System.out.println(publicId);
-    System.out.println(systemId);
+    System.out.print(name);
+    System.out.print(publicId);
+    System.out.print(systemId);
     return;
    }
    
-   /** All are reported after startDocument and before startElement event*/
+   /** All are reported after startDocument and before first startElement event*/
    public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
             throws SAXException
    {
@@ -56,10 +56,9 @@
     System.out.print(publicId);
     System.out.print(systemId);
     System.out.println(notationName);
-    Connection conn = DBEntityResolver.conn;
     String doctype = DBEntityResolver.doctype;
-    if ( getEntitySystemID(conn, doctype, publicId) == "" ) 
-        registerEntityPublicID(conn, doctype, publicId, systemId);
+    //if ( getEntitySystemID(conn, doctype, publicId) == "" ) 
+    //    registerEntityPublicID(conn, doctype, publicId, systemId);
     return;
    }
 
@@ -71,7 +70,7 @@
         Statement stmt;
         try {
           stmt = conn.createStatement();
-          stmt.execute("SELECT system_id FROM xml_catalog_entities " + 
+          stmt.execute("SELECT system_id FROM xml_catalog " + 
                        "WHERE entity_type = 'ENTITY' AND source_doctype = '" + doctype + "' AND public_id = '" + publicId + "'");
           try {
             ResultSet rs = stmt.getResultSet();
@@ -81,18 +80,18 @@
                 try {
                   system_id = rs.getString(1);
                 } catch (SQLException e) {
-                  System.out.println("DBEntityResolver.getEntitySystemID() - Error with getString: " + e.getMessage());
+                  System.out.println("DBDTDHandler.getEntitySystemID() - Error with getString: " + e.getMessage());
                 }
               }
             } catch (SQLException e) {
-              System.out.println("DBEntityResolver.getEntitySystemID() - Error with next: " + e.getMessage());
+              System.out.println("DBDTDHandler.getEntitySystemID() - Error with next: " + e.getMessage());
             }
           } catch (SQLException e) {
-            System.out.println("DBEntityResolver.getEntitySystemID() - Error with getrset: " + e.getMessage());
+            System.out.println("DBDTDHandler.getEntitySystemID() - Error with getrset: " + e.getMessage());
           }
           stmt.close();
         } catch (SQLException e) {
-          System.out.println("DBEntityResolver.getEntitySystemID() - Error getting id: " + e.getMessage());
+          System.out.println("DBDTDHandler.getEntitySystemID() - Error getting id: " + e.getMessage());
         }
 
         // return the selected System ID
@@ -106,7 +105,7 @@
           conn.setAutoCommit(false);
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog_entities (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
+                "INSERT INTO xml_catalog (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
                 "VALUES (null, null, 'ENTITY', ?, ?, ?)");
           // Bind the values to the query
           pstmt.setString(1, doctype);
Index: DBSAXElement.java
===================================================================
--- DBSAXElement.java	(revision 91)
+++ DBSAXElement.java	(revision 92)
@@ -74,17 +74,18 @@
     }
 
     /** creates SQL code and inserts comment into DB connection */
-    void writeCommentToDB(String data) {
+    void writeCommentToDB(String data, int nodeIndex) {
         try {
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
                 "INSERT INTO xml_nodes (nodeid, nodetype, " +
-                "nodename, parentnodeid, nodedata) VALUES (null, ?, null, ?, ?)");
+                "nodename, parentnodeid, nodedata, nodeindex) VALUES (null, ?, null, ?, ?, ?)");
 
           // Bind the values to the query
           pstmt.setString(1, "COMMENT");
           pstmt.setLong(2, getElementID());
           pstmt.setString(3, data);
+          pstmt.setInt(4, nodeIndex);
           // Do the insertion
           pstmt.execute();
           pstmt.close();
Index: DBSAXHandler.java
===================================================================
--- DBSAXHandler.java	(revision 91)
+++ DBSAXHandler.java	(revision 92)
@@ -33,7 +33,7 @@
 {
 
    static int elementNo = 0;
-   private String docname;
+   static String docname;
    private String doctype;
    private String systemid;
    private boolean 	debug 	= false;
@@ -76,9 +76,6 @@
     // here is a bug: dtd.getPublicId() and dtd.getSustemId() return null.
     docname = dtd.getName();
     doctype = dtd.getPublicId();
-    //if (doctype == null) {
-      //doctype = docname;
-    //}
     systemid = dtd.getSystemId();
     System.out.println("DOCNAME: " + docname);
     System.out.println("DOCTYPE: " + doctype);
@@ -92,8 +89,11 @@
    public void endDoctype() throws SAXException
    {
     System.out.println("end of DOCTYPE");
-    if (doctype == null)
+    if (doctype == null) {
         doctype = DBEntityResolver.doctype;
+        //if (doctype == null) 
+        //    doctype = docname;
+    }
    }
 
    /** SAX Handler that is called at the start of each XML element */
@@ -117,8 +117,8 @@
       expName = name.getExpandedName();
       
       elementNo++;
-      if ((elementNo == 1) && (doctype == null))
-        throw new SAXException("No DOCTYPE declaration or PUBLIC ID provided");
+      if (docname == null)
+        throw new SAXException("No DOCTYPE declaration provided");
       // Get a reference to the parent element for the id
       long parent_id;
       int nodeIndex;
@@ -190,9 +190,17 @@
    {
     if (elementNo > 0) {
       DBSAXElement currentElement = (DBSAXElement)elementStack.peek();
-      currentElement.writeCommentToDB(data);
+      int nodeIndex = currentElement.incChildNum();
+      currentElement.writeCommentToDB(data, nodeIndex);
     }
    }
+   public void processingInstruction(String target, String data) throws SAXException
+   {
+    if (elementNo == 0)
+        System.out.println("target:" + target + "\ndata:" + data);
+    else if (elementNo > 0)
+        System.out.println("targetHere:" + target + "\ndata:" + data);
+   }
 
    /** SAX Handler that is called at the end of each XML element */
    public void endElement(NSName name) throws SAXException 
Index: DBEntityResolver.java
===================================================================
--- DBEntityResolver.java	(revision 91)
+++ DBEntityResolver.java	(revision 92)
@@ -1,5 +1,5 @@
 /**
- *        Name: DBSAXHandler.java
+ *        Name: DBEntityResolver.java
  *     Purpose: A Class that implements org.xml.sax.EntityResolver interface
  *              for resolving external entities
  *   Copyright: 2000 Regents of the University of California and the
@@ -28,7 +28,7 @@
 {
 
    static String doctype = null;
-   static Connection conn = null;
+   private Connection conn = null;
    private int pIdCounter = 0;
    private long currentElementNo;
 
@@ -51,9 +51,10 @@
    {
      String dbSystemId;
      
+     currentElementNo = DBSAXHandler.elementNo;
+     
      if (publicId != null) {
         pIdCounter += 1;
-        currentElementNo = DBSAXHandler.elementNo;
         System.out.println("from DBEntityResolver: current element is " + DBSAXHandler.elementNo);
         System.out.println("from DBEntityResolver: " + pIdCounter + " " + publicId);
         // look at the db XML Catalog and get dbSystemId by this publicId
@@ -63,33 +64,33 @@
             if (dbSystemId == "")
                 // register publicId in db and use the provided systemId
                 if (systemId != "") {
-                    System.out.println("from DBEntityResolver: " + systemId);
                     new URL(systemId);
-                    registerDTDPublicID (conn, publicId, systemId);
+                    registerDTDPublicID (conn, doctype, publicId, systemId);
                     return null;
                 }
             new URL(dbSystemId);
-            System.out.println("from DBEntityResolver: db System ID: " + dbSystemId);
             return new InputSource(dbSystemId);
         } 
-        else {
+        /*else {
             // look at the db XML Catalog and get dbSystemId by this publicId for a given doctype
             dbSystemId = getEntitySystemID (conn, doctype, publicId);
             if (dbSystemId == "")
                 // register publicId in db for a given doctype and use the provided systemId
                 if (systemId != "") {
-                    System.out.println("from DBEntityResolver: " + systemId);
                     new URL(systemId);
                     registerEntityPublicID (conn, doctype, publicId, systemId);
                     return null;
                 }
             new URL(dbSystemId);
-            System.out.println("from DBEntityResolver: db System ID: " + dbSystemId);
             return new InputSource(dbSystemId);
-        }  
+        }*/  
      }
+     // publicId is null => doctype is null => doctype = docname
      if ( systemId != null) {
-        System.out.println("from DBEntityResolver: " + systemId);
+        if (currentElementNo == 0) {
+            doctype = DBSAXHandler.docname;
+            registerDTDPublicID (conn, doctype, "", systemId);
+        }
         new URL(systemId);
      }
     
@@ -105,8 +106,8 @@
         Statement stmt;
         try {
           stmt = conn.createStatement();
-          stmt.execute("SELECT system_id FROM xml_catalog_entities a, xml_catalog b " + 
-                       "WHERE a.entity_type = 'DTD' AND a.source_doctype = b.doctype AND b.doctype = '" + publicId + "'");
+          stmt.execute("SELECT system_id FROM xml_catalog " + 
+                       "WHERE entity_type = 'DTD' AND source_doctype = '" + publicId + "'");
           try {
             ResultSet rs = stmt.getResultSet();
             try {
@@ -127,6 +128,7 @@
           stmt.close();
         } catch (SQLException e) {
           System.out.println("DBEntityResolver.getDTDSystemID() - Error getting id: " + e.getMessage());
+          System.exit(1);
         }
 
         // return the selected System ID
@@ -134,27 +136,21 @@
    }
 
    /** Register Public ID in db XML Catalog */
-   private void registerDTDPublicID (Connection conn, String publicId, String systemId)
+   private void registerDTDPublicID (Connection conn, String doctype, String publicId, String systemId)
    {
         try {
           conn.setAutoCommit(false);
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog (doctype) VALUES (?)");
+                "INSERT INTO xml_catalog (entity_id, entity_type, source_doctype, public_id, system_id) " +
+                "VALUES (null, 'DTD', ?, ?, ?)");
           // Bind the values to the query
-          pstmt.setString(1, publicId);
+          pstmt.setString(1, doctype);
+          pstmt.setString(2, publicId);
+          pstmt.setString(3, systemId);
           // Do the insertion
           pstmt.execute();
           pstmt.close();
-          pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog_entities (entity_id, entity_type, source_doctype, system_id) " +
-                "VALUES (null, 'DTD', ?, ?)");
-          // Bind the values to the query
-          pstmt.setString(1, publicId);
-          pstmt.setString(2, systemId);
-          // Do the insertion
-          pstmt.execute();
-          pstmt.close();
           conn.commit();
           conn.setAutoCommit(true);
         } catch (SQLException e) {
@@ -170,7 +166,7 @@
         Statement stmt;
         try {
           stmt = conn.createStatement();
-          stmt.execute("SELECT system_id FROM xml_catalog_entities " + 
+          stmt.execute("SELECT system_id FROM xml_catalog " + 
                        "WHERE entity_type = 'ENTITY' AND source_doctype = '" + doctype + "' AND public_id = '" + publicId + "'");
           try {
             ResultSet rs = stmt.getResultSet();
@@ -205,7 +201,7 @@
           conn.setAutoCommit(false);
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog_entities (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
+                "INSERT INTO xml_catalog (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
                 "VALUES (null, null, 'ENTITY', ?, ?, ?)");
           // Bind the values to the query
           pstmt.setString(1, doctype);
Index: DBDTDHandler.java
===================================================================
--- DBDTDHandler.java	(revision 91)
+++ DBDTDHandler.java	(revision 92)
@@ -41,13 +41,13 @@
             throws SAXException
    {
     System.out.println("from DBDTDHandler.notationDecl");
-    System.out.println(name);
-    System.out.println(publicId);
-    System.out.println(systemId);
+    System.out.print(name);
+    System.out.print(publicId);
+    System.out.print(systemId);
     return;
    }
    
-   /** All are reported after startDocument and before startElement event*/
+   /** All are reported after startDocument and before first startElement event*/
    public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)
             throws SAXException
    {
@@ -56,10 +56,9 @@
     System.out.print(publicId);
     System.out.print(systemId);
     System.out.println(notationName);
-    Connection conn = DBEntityResolver.conn;
     String doctype = DBEntityResolver.doctype;
-    if ( getEntitySystemID(conn, doctype, publicId) == "" ) 
-        registerEntityPublicID(conn, doctype, publicId, systemId);
+    //if ( getEntitySystemID(conn, doctype, publicId) == "" ) 
+    //    registerEntityPublicID(conn, doctype, publicId, systemId);
     return;
    }
 
@@ -71,7 +70,7 @@
         Statement stmt;
         try {
           stmt = conn.createStatement();
-          stmt.execute("SELECT system_id FROM xml_catalog_entities " + 
+          stmt.execute("SELECT system_id FROM xml_catalog " + 
                        "WHERE entity_type = 'ENTITY' AND source_doctype = '" + doctype + "' AND public_id = '" + publicId + "'");
           try {
             ResultSet rs = stmt.getResultSet();
@@ -81,18 +80,18 @@
                 try {
                   system_id = rs.getString(1);
                 } catch (SQLException e) {
-                  System.out.println("DBEntityResolver.getEntitySystemID() - Error with getString: " + e.getMessage());
+                  System.out.println("DBDTDHandler.getEntitySystemID() - Error with getString: " + e.getMessage());
                 }
               }
             } catch (SQLException e) {
-              System.out.println("DBEntityResolver.getEntitySystemID() - Error with next: " + e.getMessage());
+              System.out.println("DBDTDHandler.getEntitySystemID() - Error with next: " + e.getMessage());
             }
           } catch (SQLException e) {
-            System.out.println("DBEntityResolver.getEntitySystemID() - Error with getrset: " + e.getMessage());
+            System.out.println("DBDTDHandler.getEntitySystemID() - Error with getrset: " + e.getMessage());
           }
           stmt.close();
         } catch (SQLException e) {
-          System.out.println("DBEntityResolver.getEntitySystemID() - Error getting id: " + e.getMessage());
+          System.out.println("DBDTDHandler.getEntitySystemID() - Error getting id: " + e.getMessage());
         }
 
         // return the selected System ID
@@ -106,7 +105,7 @@
           conn.setAutoCommit(false);
           PreparedStatement pstmt;
           pstmt = conn.prepareStatement(
-                "INSERT INTO xml_catalog_entities (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
+                "INSERT INTO xml_catalog (entity_id, entity_name, entity_type, source_doctype, public_id, system_id) " +
                 "VALUES (null, null, 'ENTITY', ?, ?, ?)");
           // Bind the values to the query
           pstmt.setString(1, doctype);
