* nodes for the passed node.
*/
public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
throws SQLException
{
final IDatabaseObjectInfo parentDbinfo = parentNode.getDatabaseObjectInfo();
final ISQLConnection conn = session.getSQLConnection();
final SQLDatabaseMetaData md = conn.getSQLMetaData();
boolean supportsCatalogs = false;
try
{
supportsCatalogs = md.supportsCatalogs();
}
catch (SQLException ex)
{
s_log.debug("DBMS doesn't support 'supportsCatalogs()", ex);
}
boolean supportsSchemas = false;
try
{
supportsSchemas = md.supportsSchemas();
}
catch (SQLException ex)
{
s_log.debug("DBMS doesn't support 'supportsSchemas()", ex);
}
List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
if (parentDbinfo.getDatabaseObjectType() == DatabaseObjectType.SESSION)
{
// If a driver says it supports schemas/catalogs but doesn't
// provide schema/catalog nodes, try to get other nodes.
List<ObjectTreeNode> addedChildren = new ArrayList<ObjectTreeNode>();
if (supportsCatalogs)
{
addedChildren = createCatalogNodes(session, md);
childNodes.addAll(addedChildren);
}
// else if (supportsSchemas)
if (addedChildren.size() == 0 && supportsSchemas)
{
addedChildren = createSchemaNodes(session, md, null);
childNodes.addAll(addedChildren);
}
// else
if (addedChildren.size() == 0)
{
childNodes.addAll(createObjectTypeNodes(session, null, null));
}
}
else if (parentDbinfo.getDatabaseObjectType() == DatabaseObjectType.CATALOG)
{
// If a driver says it supports schemas but doesn't
// provide schema nodes, try to get other nodes.
final String catalogName = parentDbinfo.getSimpleName();
List<ObjectTreeNode> addedChildren = new ArrayList<ObjectTreeNode>();
if (supportsSchemas)
{
addedChildren = createSchemaNodes(session, md, catalogName);
childNodes.addAll(addedChildren);
}
//else
if (addedChildren.size() == 0)
{
childNodes.addAll(createObjectTypeNodes(session, catalogName, null));
}
}
else if (parentDbinfo.getDatabaseObjectType() == DatabaseObjectType.SCHEMA)
{
final String catalogName = parentDbinfo.getCatalogName();
final String schemaName = parentDbinfo.getSimpleName();
childNodes.addAll(createObjectTypeNodes(session, catalogName, schemaName));
}
return childNodes;
}