diff options
author | Eike Stepper | 2010-05-31 09:45:47 +0000 |
---|---|---|
committer | Eike Stepper | 2010-05-31 09:45:47 +0000 |
commit | 0e371c1e12b369c0d5d74ff17c966a3354becb74 (patch) | |
tree | d219a0c63f1b0127041cce8bf2c1fad1a07dea86 /plugins/org.eclipse.net4j.db | |
parent | b4b7a35313a6ec5980c190f2f04da3e960477d96 (diff) | |
download | cdo-0e371c1e12b369c0d5d74ff17c966a3354becb74.tar.gz cdo-0e371c1e12b369c0d5d74ff17c966a3354becb74.tar.xz cdo-0e371c1e12b369c0d5d74ff17c966a3354becb74.zip |
DBBrowser for HibernateStore
Diffstat (limited to 'plugins/org.eclipse.net4j.db')
-rw-r--r-- | plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java index ef59912763..4d2039966b 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java @@ -238,6 +238,51 @@ public final class DBUtil return null; } + /** + * @since 3.0 + */ + public static List<String> getAllSchemaTableNames(Connection connection) + { + try + { + DatabaseMetaData metaData = connection.getMetaData(); + return getAllSchemaTableNames(metaData); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + } + + /** + * @since 3.0 + */ + public static List<String> getAllSchemaTableNames(DatabaseMetaData metaData) + { + ResultSet schemas = null; + + try + { + List<String> names = new ArrayList<String>(); + schemas = metaData.getSchemas(); + while (schemas.next()) + { + String name = schemas.getString(1); + names.add(name); + } + + return names; + } + catch (SQLException ex) + { + throw new DBException(ex); + } + finally + { + close(schemas); + } + } + public static List<String> getAllTableNames(Connection connection, String dbName) { ResultSet tables = null; @@ -246,10 +291,21 @@ public final class DBUtil { List<String> names = new ArrayList<String>(); DatabaseMetaData metaData = connection.getMetaData(); - tables = metaData.getTables(null, dbName.toUpperCase(), null, new String[] { "TABLE" }); //$NON-NLS-1$ + if (dbName != null) + { + dbName = dbName.toUpperCase(); + List<String> schemaNames = getAllSchemaTableNames(metaData); + if (!schemaNames.contains(dbName)) + { + dbName = null; + } + } + + tables = metaData.getTables(null, dbName, null, new String[] { "TABLE" }); //$NON-NLS-1$ while (tables.next()) { String name = tables.getString(3); + System.out.println(tables.getString(2) + "." + name); names.add(name); } |