Return-Path: Delivered-To: apmail-db-ddlutils-dev-archive@www.apache.org Received: (qmail 21662 invoked from network); 16 Jan 2006 16:51:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Jan 2006 16:51:03 -0000 Received: (qmail 19116 invoked by uid 500); 16 Jan 2006 16:51:02 -0000 Delivered-To: apmail-db-ddlutils-dev-archive@db.apache.org Received: (qmail 19093 invoked by uid 500); 16 Jan 2006 16:51:02 -0000 Mailing-List: contact ddlutils-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ddlutils-dev@db.apache.org Delivered-To: mailing list ddlutils-dev@db.apache.org Received: (qmail 19077 invoked by uid 500); 16 Jan 2006 16:51:02 -0000 Delivered-To: apmail-db-ddlutils-commits@db.apache.org Received: (qmail 19071 invoked by uid 99); 16 Jan 2006 16:51:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jan 2006 08:51:02 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 16 Jan 2006 08:51:01 -0800 Received: (qmail 21437 invoked by uid 65534); 16 Jan 2006 16:50:41 -0000 Message-ID: <20060116165041.21436.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r369524 - /db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java Date: Mon, 16 Jan 2006 16:50:41 -0000 To: ddlutils-commits@db.apache.org From: tomdz@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: tomdz Date: Mon Jan 16 08:50:38 2006 New Revision: 369524 URL: http://svn.apache.org/viewcvs?rev=369524&view=rev Log: Enhanced the dump metadata task to give more info when access to the db fails Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java?rev=369524&r1=369523&r2=369524&view=diff ============================================================================== --- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java (original) +++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java Mon Jan 16 08:50:38 2006 @@ -33,6 +33,7 @@ import org.apache.commons.collections.set.ListOrderedSet; import org.apache.commons.dbcp.BasicDataSource; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.dom4j.Document; import org.dom4j.DocumentFactory; @@ -430,9 +431,20 @@ */ private void dumpTables(Element parent, DatabaseMetaData metaData, String[] tableTypes) throws SQLException { - ResultSet result = metaData.getTables(_catalogPattern, _schemaPattern, _tablePattern, tableTypes); - Element tablesElem = parent.addElement("tables"); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getTables(_catalogPattern, _schemaPattern, _tablePattern, tableTypes); + } + catch (SQLException ex) + { + log("Could not determine the tables: "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Element tablesElem = parent.addElement("tables"); + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -475,8 +487,19 @@ */ private void dumpColumns(Element tableElem, DatabaseMetaData metaData, String catalogName, String schemaName, String tableName) throws SQLException { - ResultSet result = metaData.getColumns(catalogName, schemaName, tableName, _columnPattern); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getColumns(catalogName, schemaName, tableName, _columnPattern); + } + catch (SQLException ex) + { + log("Could not determine the columns for table '"+tableName+"': "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -549,8 +572,19 @@ */ private void dumpPKs(Element tableElem, DatabaseMetaData metaData, String catalogName, String schemaName, String tableName) throws SQLException { - ResultSet result = metaData.getPrimaryKeys(catalogName, schemaName, tableName); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getPrimaryKeys(catalogName, schemaName, tableName); + } + catch (SQLException ex) + { + log("Could not determine the primary key columns for table '"+tableName+"': "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -580,8 +614,19 @@ */ private void dumpVersionColumns(Element tableElem, DatabaseMetaData metaData, String catalogName, String schemaName, String tableName) throws SQLException { - ResultSet result = metaData.getVersionColumns(catalogName, schemaName, tableName); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getVersionColumns(catalogName, schemaName, tableName); + } + catch (SQLException ex) + { + log("Could not determine the versioned columns for table '"+tableName+"': "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -629,8 +674,19 @@ */ private void dumpFKs(Element tableElem, DatabaseMetaData metaData, String catalogName, String schemaName, String tableName) throws SQLException { - ResultSet result = metaData.getImportedKeys(catalogName, schemaName, tableName); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getImportedKeys(catalogName, schemaName, tableName); + } + catch (SQLException ex) + { + log("Could not determine the foreign keys for table '"+tableName+"': "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -719,8 +775,19 @@ */ private void dumpIndices(Element tableElem, DatabaseMetaData metaData, String catalogName, String schemaName, String tableName) throws SQLException { - ResultSet result = metaData.getIndexInfo(catalogName, schemaName, tableName, false, false); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getIndexInfo(catalogName, schemaName, tableName, false, false); + } + catch (SQLException ex) + { + log("Could not determine the indices for table '"+tableName+"': "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -783,9 +850,20 @@ */ private void dumpProcedures(Element parent, DatabaseMetaData metaData) throws SQLException { - ResultSet result = metaData.getProcedures(_catalogPattern, _schemaPattern, _procedurePattern); - Element proceduresElem = parent.addElement("procedures"); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getProcedures(_catalogPattern, _schemaPattern, _procedurePattern); + } + catch (SQLException ex) + { + log("Could not determine the procedures: "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Element proceduresElem = parent.addElement("procedures"); + Set columns = getColumnsInResultSet(result); while (result.next()) { @@ -836,8 +914,19 @@ */ private void dumpProcedure(Element procedureElem, DatabaseMetaData metaData, String catalogName, String schemaName, String procedureName) throws SQLException { - ResultSet result = metaData.getProcedureColumns(catalogName, schemaName, procedureName, _columnPattern); - Set columns = getColumnsInResultSet(result); + ResultSet result = null; + + try + { + result = metaData.getProcedureColumns(catalogName, schemaName, procedureName, _columnPattern); + } + catch (SQLException ex) + { + log("Could not determine the columns for procedure '"+procedureName+"': "+ex.getMessage(), Project.MSG_ERR); + return; + } + + Set columns = getColumnsInResultSet(result); while (result.next()) {