From e9f030493a87f7cc727983afcd1fa1d378826230 Mon Sep 17 00:00:00 2001 From: johncurrier Date: Tue, 3 Jul 2007 19:15:10 +0000 Subject: [PATCH] Bug 1747079 - no longer dies when it can't evaluate a view --- src/net/sourceforge/schemaspy/model/Database.java | 15 ++++++++++++--- src/net/sourceforge/schemaspy/model/Table.java | 12 ++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/net/sourceforge/schemaspy/model/Database.java b/src/net/sourceforge/schemaspy/model/Database.java index 6a82ff9..d206915 100755 --- a/src/net/sourceforge/schemaspy/model/Database.java +++ b/src/net/sourceforge/schemaspy/model/Database.java @@ -523,9 +523,18 @@ private void initViews(String schema, DatabaseMetaData metadata, Properties prop if (rs.getString("TABLE_TYPE").equals("VIEW")) { // some databases (MySQL) return more than we wanted System.out.print('.'); - Table view = new View(this, rs, properties.getProperty("selectViewSql")); - if (include.matcher(view.getName()).matches()) - views.put(view.getName().toUpperCase(), view); + try { + Table view = new View(this, rs, properties.getProperty("selectViewSql")); + + if (include.matcher(view.getName()).matches()) + views.put(view.getName().toUpperCase(), view); + } catch (SQLException exc) { + System.out.flush(); + System.err.println(); + System.err.println("Ignoring view due to exception:"); + exc.printStackTrace(); + System.err.println("Continuing analysis."); + } } } } finally { diff --git a/src/net/sourceforge/schemaspy/model/Table.java b/src/net/sourceforge/schemaspy/model/Table.java index d67c12b..7611157 100755 --- a/src/net/sourceforge/schemaspy/model/Table.java +++ b/src/net/sourceforge/schemaspy/model/Table.java @@ -158,8 +158,16 @@ private void initColumns(Database db) throws SQLException { while (rs.next()) addColumn(rs); } catch (SQLException exc) { - System.err.println("Failed to collect column details for table '" + getName() + "' in schema '" + getSchema() + "'"); - throw exc; + class ColumnInitializationFailure extends SQLException { + private static final long serialVersionUID = 1L; + + public ColumnInitializationFailure(SQLException failure) { + super("Failed to collect column details for " + (isView() ? "view" : "table") + " '" + getName() + "' in schema '" + getSchema() + "'"); + initCause(failure); + } + } + + throw new ColumnInitializationFailure(exc); } finally { if (rs != null) rs.close();