1 package org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel; 2 16 17 22 public class DBMetaTableNode extends ReverseDbTreeNode 23 implements java.io.Serializable 24 { 25 static final long serialVersionUID = 7091783312165332145L; 26 27 public static final String ATT_TABLE_NAME = "Table Name"; 28 29 35 public DBMetaTableNode(java.sql.DatabaseMetaData pdbMeta, 36 DatabaseMetaDataTreeModel pdbMetaTreeModel, 37 DBMetaSchemaNode pschemaNode, 38 String pstrTableName) 39 { 40 super(pdbMeta, pdbMetaTreeModel, pschemaNode); 41 this.setAttribute(ATT_TABLE_NAME, pstrTableName); 42 } 43 44 47 public boolean getAllowsChildren() 48 { 49 return true; 50 } 51 52 55 public boolean isLeaf() 56 { 57 return false; 58 } 59 60 64 public String getTableName() 65 { 66 return (String )this.getAttribute(ATT_TABLE_NAME); 67 } 68 69 72 public String toString() 73 { 74 return (String )getAttribute(ATT_TABLE_NAME); 75 } 76 77 80 public DBMetaSchemaNode getSchema() 81 { 82 return (DBMetaSchemaNode)this.getParent(); 83 } 84 85 public Class getPropertyEditorClass() 86 { 87 return org.apache.ojb.tools.mapping.reversedb2.propertyEditors.JPnlPropertyEditorDBMetaTable.class; 88 } 89 90 91 94 protected boolean _load () 95 { 96 java.sql.ResultSet rs = null; 97 try 98 { 99 synchronized(getDbMeta()) 104 { 105 getDbMetaTreeModel().setStatusBarMessage("Reading columns for table " + getSchema().getCatalog().getCatalogName() + "." + getSchema().getSchemaName() + "." + getTableName()); 106 rs = getDbMeta().getColumns(getSchema().getCatalog().getCatalogName(), 107 getSchema().getSchemaName(), 108 getTableName(), "%"); 109 final java.util.ArrayList alNew = new java.util.ArrayList (); 110 while (rs.next()) 111 { 112 alNew.add(new DBMetaColumnNode(getDbMeta(), getDbMetaTreeModel(), DBMetaTableNode.this, rs.getString("COLUMN_NAME"))); 113 } 114 alChildren = alNew; 115 javax.swing.SwingUtilities.invokeLater(new Runnable () 116 { 117 public void run() 118 { 119 getDbMetaTreeModel().nodeStructureChanged(DBMetaTableNode.this); 120 } 121 }); 122 rs.close(); 123 } 124 } 125 catch (java.sql.SQLException sqlEx) 126 { 127 this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx); 128 try 129 { 130 if (rs != null) rs.close (); 131 } 132 catch (java.sql.SQLException sqlEx2) 133 { 134 this.getDbMetaTreeModel().reportSqlError("Error retrieving columns", sqlEx2); 135 } 136 return false; 137 } 138 return true; 139 } 140 141 } 142 | Popular Tags |