You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-dev@db.apache.org by to...@apache.org on 2006/01/16 17:50:41 UTC
svn commit: r369524 -
/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DumpMetadataTask.java
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())
{