1 package org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel; 2 16 17 24 public class DBMetaCatalogNode extends ReverseDbTreeNode 25 implements java.io.Serializable 26 { 27 static final long serialVersionUID = -2455228985120104948L; 28 public static final String ATT_CATALOG_NAME = "Catalog Name"; 29 30 31 38 public DBMetaCatalogNode(java.sql.DatabaseMetaData pdbMeta, 39 DatabaseMetaDataTreeModel pdbMetaTreeModel, 40 DBMetaRootNode prootNode, 41 String pstrCatalogName) 42 { 43 super(pdbMeta, pdbMetaTreeModel, prootNode); 44 this.setAttribute(ATT_CATALOG_NAME, pstrCatalogName); 45 } 46 47 50 public boolean isLeaf() 51 { 52 return false; 53 } 54 55 58 public boolean getAllowsChildren() 59 { 60 return false; 61 } 62 63 67 public String getCatalogName() 68 { 69 return (String )this.getAttribute(ATT_CATALOG_NAME); 70 } 71 72 78 public String toString() 79 { 80 if (this.getAttribute(ATT_CATALOG_NAME) != null) 81 return this.getAttribute(ATT_CATALOG_NAME).toString(); 82 else return "catalog not specified"; 83 } 84 85 public Class getPropertyEditorClass() 86 { 87 return org.apache.ojb.tools.mapping.reversedb2.propertyEditors.JPnlPropertyEditorDBMetaCatalog.class; 88 } 89 90 93 protected boolean _load () 94 { 95 java.sql.ResultSet rs = null; 96 try 97 { 98 99 synchronized(getDbMeta()) 104 { 105 106 getDbMetaTreeModel().setStatusBarMessage("Reading schemas for catalog " 107 + this.getAttribute(ATT_CATALOG_NAME)); 108 rs = getDbMeta().getSchemas(); 109 final java.util.ArrayList alNew = new java.util.ArrayList (); 110 int count = 0; 111 while (rs.next()) 112 { 113 getDbMetaTreeModel().setStatusBarMessage("Creating schema " + getCatalogName() + "." + rs.getString("TABLE_SCHEM")); 114 alNew.add(new DBMetaSchemaNode(getDbMeta(), 115 getDbMetaTreeModel(), 116 DBMetaCatalogNode.this, 117 rs.getString("TABLE_SCHEM"))); 118 count++; 119 } 120 if (count == 0) 121 alNew.add(new DBMetaSchemaNode(getDbMeta(), 122 getDbMetaTreeModel(), 123 DBMetaCatalogNode.this, null)); 124 alChildren = alNew; 125 javax.swing.SwingUtilities.invokeLater(new Runnable () 126 { 127 public void run() 128 { 129 getDbMetaTreeModel().nodeStructureChanged(DBMetaCatalogNode.this); 130 } 131 }); 132 rs.close(); 133 } 134 } 135 catch (java.sql.SQLException sqlEx) 136 { 137 getDbMetaTreeModel().reportSqlError("Error retrieving schemas", sqlEx); 138 try 139 { 140 if (rs != null) rs.close (); 141 } 142 catch (java.sql.SQLException sqlEx2) 143 { 144 this.getDbMetaTreeModel().reportSqlError("Error retrieving schemas", sqlEx2); 145 } 146 return false; 147 } 148 return true; 149 } 150 151 } 152 | Popular Tags |