1 package org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel; 2 3 4 5 19 20 27 public class DBMetaRootNode extends ReverseDbTreeNode 28 implements java.io.Serializable 29 { 30 static final long serialVersionUID = 5002948511759554049L; 34 public DBMetaRootNode(java.sql.DatabaseMetaData pdbMeta, 35 DatabaseMetaDataTreeModel pdbMetaTreeModel) 36 { 37 super(pdbMeta, pdbMetaTreeModel, null); 38 } 39 40 43 public boolean isLeaf() 44 { 45 return false; 46 } 47 48 51 public boolean getAllowsChildren() 52 { 53 return false; 54 } 55 56 59 public String toString() 60 { 61 return "Root"; 62 } 63 64 public Class getPropertyEditorClass() 65 { 66 return null; 67 } 68 69 72 protected boolean _load () 73 { 74 java.sql.ResultSet rs = null; 75 try 76 { 77 synchronized(getDbMeta()) 82 { 83 getDbMetaTreeModel().setStatusBarMessage("Started reading catalogs"); 84 rs = getDbMeta().getCatalogs(); 85 final java.util.ArrayList alNew = new java.util.ArrayList (); 86 int count = 0; 87 while (rs.next()) 88 { 89 getDbMetaTreeModel().setStatusBarMessage("Reading catalog " + rs.getString("TABLE_CAT")); 90 alNew.add(new DBMetaCatalogNode(getDbMeta(), getDbMetaTreeModel(), 91 DBMetaRootNode.this, rs.getString("TABLE_CAT"))); 92 count++; 93 } 94 if (count == 0) 95 alNew.add(new DBMetaCatalogNode(getDbMeta(), getDbMetaTreeModel(), 96 DBMetaRootNode.this, null)); 97 alChildren = alNew; 98 javax.swing.SwingUtilities.invokeLater(new Runnable () 99 { 100 public void run() 101 { 102 getDbMetaTreeModel().nodeStructureChanged(DBMetaRootNode.this); 103 } 104 }); 105 rs.close(); 106 } 107 } 108 catch (java.sql.SQLException sqlEx) 109 { 110 getDbMetaTreeModel().reportSqlError("Error retrieving catalogs", sqlEx); 111 try 112 { 113 if (rs != null) rs.close (); 114 } 115 catch (java.sql.SQLException sqlEx2) 116 { 117 this.getDbMetaTreeModel().reportSqlError("Error retrieving catalogs", sqlEx2); 118 } 119 return false; 120 } 121 return true; 122 } 123 } 124 | Popular Tags |