vgritsenko 02/01/10 07:56:32 Modified: src/java/org/apache/cocoon/components/source XMLDBSource.java Log: Improve error handling Revision Changes Path 1.3 +18 -22 xml-cocoon2/src/java/org/apache/cocoon/components/source/XMLDBSource.java Index: XMLDBSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/XMLDBSource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XMLDBSource.java 3 Jan 2002 14:56:55 -0000 1.2 +++ XMLDBSource.java 10 Jan 2002 15:56:32 -0000 1.3 @@ -5,7 +5,6 @@ * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ - package org.apache.cocoon.components.source; import org.apache.avalon.framework.component.ComponentException; @@ -50,14 +49,10 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Gianugo Rabellino</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version $Id: XMLDBSource.java,v 1.2 2002/01/03 14:56:55 cziegeler Exp $ + * @version $Id: XMLDBSource.java,v 1.3 2002/01/10 15:56:32 vgritsenko Exp $ */ - public class XMLDBSource extends AbstractSAXSource { - /** The Database instance */ - protected Database database; - /** The driver implementation class */ protected String driver; @@ -116,7 +111,6 @@ * @param url the URL being queried. * @param driver the XML:DB driver class name. */ - public XMLDBSource(Environment environment, ComponentManager manager, Logger logger, @@ -140,31 +134,30 @@ * Initialize the XML:DB connection. * */ - public void connect() throws ProcessingException { if (log.isDebugEnabled()) { - this.log.debug("Initializing XML:DB connection"); + this.log.debug("Initializing XML:DB connection, using driver " + driver); } try { Class c = Class.forName(driver); - database = (Database)c.newInstance(); - DatabaseManager.registerDatabase(database); + DatabaseManager.registerDatabase((Database)c.newInstance()); } catch (XMLDBException xde) { - this.log.error("Unable to connect to the XML:DB database"); - throw new ProcessingException("Unable to connect to the XMLDB database" - + xde.getMessage()); + String error = "Unable to connect to the XMLDB database. Error " + + xde.errorCode + ": " + xde.getMessage(); + this.log.debug(error, xde); + throw new ProcessingException(error, xde); } catch (Exception e) { this.log.error("There was a problem setting up the connection"); this.log.error("Make sure that your driver is available"); - throw new ProcessingException("Problem setting up the connection: " + throw new ProcessingException("Problem setting up the connection to XML:DB: " + e.getMessage(), e); } @@ -178,7 +171,6 @@ * resource is a collection, build an XML view of it. * */ - public void toSAX(ContentHandler handler) throws SAXException, ProcessingException { if (!connected) { @@ -225,8 +217,10 @@ collection.close(); } catch (XMLDBException xde) { - throw new ProcessingException("Unable to fetch content: " + - xde.getMessage(), xde); + String error = "Unable to fetch content. Error " + + xde.errorCode + ": " + xde.getMessage(); + this.log.debug(error, xde); + throw new SAXException(error, xde); } } @@ -294,8 +288,9 @@ collection.close(); } catch (XMLDBException xde) { - this.log.error("Collection listing failed. " + xde.getMessage()); - throw new SAXException("Collection listing failed. " + xde.getMessage()); + String error = "Collection listing failed. Error " + xde.errorCode + ": " + xde.getMessage(); + this.log.debug(error, xde); + throw new SAXException(error, xde); } } @@ -347,8 +342,9 @@ handler.endPrefixMapping(PREFIX); handler.endDocument(); } catch (XMLDBException xde) { - this.log.error("Query failed. " + xde.getMessage()); - throw new SAXException("Query failed. " + xde.getMessage()); + String error = "Query failed. Error " + xde.errorCode + ": " + xde.getMessage(); + this.log.debug(error, xde); + throw new SAXException(error, xde); } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]