Source Code Cross Referenced for DBMetaSchemaNode.java in  » Database-ORM » db-ojb » org » apache » ojb » tools » mapping » reversedb2 » dbmetatreemodel » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » db ojb » org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.tools.mapping.reversedb2.dbmetatreemodel;
002:
003:        /* Copyright 2002-2005 The Apache Software Foundation
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /**
019:         * This node represents a schema of the database. Its children are DBMetaTableNode
020:         * objects. Not all databases support schemas (e.g. MySQL), so the schema name
021:         * may be null.
022:         * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
023:         * @version $Id: DBMetaSchemaNode.java,v 1.1.2.1 2005/12/21 22:32:42 tomdz Exp $
024:         */
025:        public class DBMetaSchemaNode extends ReverseDbTreeNode implements 
026:                java.io.Serializable {
027:            static final long serialVersionUID = 2430983502951445144L;
028:            /** Key for accessing the schema name in the attributes Map */
029:            public static final String ATT_SCHEMA_NAME = "Schema Name";
030:
031:            /** Creates a new instance of DBMetaSchemaNode 
032:             * @param pdbMeta DatabaseMetaData implementation where this node gets its data from.
033:             * @param pdbMetaTreeModel The TreeModel this node is associated to.
034:             * @param pcatalogNode The parent node for this node.
035:             * @param pstrSchemaName The name of the schema this node is representing. Some databases do not support
036:             * schemas, therefore null values are allowed for this parameter     
037:             */
038:            public DBMetaSchemaNode(java.sql.DatabaseMetaData pdbMeta,
039:                    DatabaseMetaDataTreeModel pdbMetaTreeModel,
040:                    DBMetaCatalogNode pcatalogNode, String pstrSchemaName) {
041:                super (pdbMeta, pdbMetaTreeModel, pcatalogNode);
042:                this .setAttribute(ATT_SCHEMA_NAME, pstrSchemaName);
043:            }
044:
045:            /**
046:             * @see ReverseDbTreeNode#isLeaf()
047:             */
048:            public boolean getAllowsChildren() {
049:                return true;
050:            }
051:
052:            /**
053:             * @see ReverseDbTreeNode#getAllowsChildren()
054:             */
055:            public boolean isLeaf() {
056:                return false;
057:            }
058:
059:            /**
060:             * Convenience access method for the schema name. Accesses the
061:             * attributes HashMap to retrieve the value.
062:             */
063:            public String getSchemaName() {
064:                return (String) this .getAttribute(ATT_SCHEMA_NAME);
065:            }
066:
067:            /**
068:             * If the schema name is specified, returns the schema name, 
069:             * otherwise a constant string indicating that the schema name
070:             * is emtpy (which is legal for some databases, e.g. MySQL)
071:             * @see Object#toString()
072:             */
073:            public String toString() {
074:                if (this .getAttribute(ATT_SCHEMA_NAME) == null)
075:                    return "Schema not specified";
076:                else
077:                    return this .getAttribute(ATT_SCHEMA_NAME).toString();
078:            }
079:
080:            /**
081:             * Convenience access method to the catalog this schema is associated to.
082:             */
083:            public DBMetaCatalogNode getCatalog() {
084:                return (DBMetaCatalogNode) getParent();
085:            }
086:
087:            public Class getPropertyEditorClass() {
088:                return org.apache.ojb.tools.mapping.reversedb2.propertyEditors.JPnlPropertyEditorDBMetaSchema.class;
089:            }
090:
091:            /**
092:             * Fills the children list with the tables this schema contains.
093:             */
094:            protected boolean _load() {
095:                java.sql.ResultSet rs = null;
096:                try {
097:                    // This synchronization is necessary for Oracle JDBC drivers 8.1.7, 9.0.1, 9.2.0.1
098:                    // The documentation says synchronization is done within the driver, but they
099:                    // must have overlooked something. Without the lock we'd get mysterious error
100:                    // messages.            
101:                    synchronized (getDbMeta()) {
102:                        getDbMetaTreeModel().setStatusBarMessage(
103:                                "Reading tables for schema "
104:                                        + getCatalog().getCatalogName() + "."
105:                                        + getSchemaName());
106:                        rs = getDbMeta().getTables(
107:                                getCatalog().getCatalogName(), getSchemaName(),
108:                                "%", null);
109:                        final java.util.ArrayList alNew = new java.util.ArrayList();
110:                        while (rs.next()) {
111:                            getDbMetaTreeModel().setStatusBarMessage(
112:                                    "Creating table "
113:                                            + getCatalog().getCatalogName()
114:                                            + "." + getSchemaName() + "."
115:                                            + rs.getString("TABLE_NAME"));
116:                            alNew.add(new DBMetaTableNode(getDbMeta(),
117:                                    getDbMetaTreeModel(),
118:                                    DBMetaSchemaNode.this , rs
119:                                            .getString("TABLE_NAME")));
120:                        }
121:                        alChildren = alNew;
122:                        javax.swing.SwingUtilities.invokeLater(new Runnable() {
123:                            public void run() {
124:                                getDbMetaTreeModel().nodeStructureChanged(
125:                                        DBMetaSchemaNode.this );
126:                            }
127:                        });
128:                        rs.close();
129:                    }
130:                } catch (java.sql.SQLException sqlEx) {
131:                    getDbMetaTreeModel().reportSqlError(
132:                            "Error retrieving tables", sqlEx);
133:                    try {
134:                        if (rs != null)
135:                            rs.close();
136:                    } catch (java.sql.SQLException sqlEx2) {
137:                        this .getDbMetaTreeModel().reportSqlError(
138:                                "Error retrieving tables", sqlEx2);
139:                    }
140:                    return false;
141:                }
142:                return true;
143:            }
144:        }
w__w__w_.___j__av___a___2___s__.c__o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.