Source Code Cross Referenced for SampleDatabase.java in  » JMX » je » collections » ship » basic » 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 » JMX » je » collections.ship.basic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-
002:         * See the file LICENSE for redistribution information.
003:         *
004:         * Copyright (c) 2002,2008 Oracle.  All rights reserved.
005:         *
006:         * $Id: SampleDatabase.java,v 1.24.2.2 2008/01/07 15:14:00 cwl Exp $
007:         */
008:
009:        package collections.ship.basic;
010:
011:        import java.io.File;
012:        import java.io.FileNotFoundException;
013:
014:        import com.sleepycat.bind.serial.StoredClassCatalog;
015:        import com.sleepycat.je.Database;
016:        import com.sleepycat.je.DatabaseConfig;
017:        import com.sleepycat.je.DatabaseException;
018:        import com.sleepycat.je.Environment;
019:        import com.sleepycat.je.EnvironmentConfig;
020:
021:        /**
022:         * SampleDatabase defines the storage containers, indices and foreign keys
023:         * for the sample database.
024:         *
025:         * @author Mark Hayes
026:         */
027:        public class SampleDatabase {
028:
029:            private static final String CLASS_CATALOG = "java_class_catalog";
030:            private static final String SUPPLIER_STORE = "supplier_store";
031:            private static final String PART_STORE = "part_store";
032:            private static final String SHIPMENT_STORE = "shipment_store";
033:
034:            private Environment env;
035:            private Database partDb;
036:            private Database supplierDb;
037:            private Database shipmentDb;
038:            private StoredClassCatalog javaCatalog;
039:
040:            /**
041:             * Open all storage containers, indices, and catalogs.
042:             */
043:            public SampleDatabase(String homeDirectory)
044:                    throws DatabaseException, FileNotFoundException {
045:
046:                // Open the Berkeley DB environment in transactional mode.
047:                //
048:                System.out.println("Opening environment in: " + homeDirectory);
049:                EnvironmentConfig envConfig = new EnvironmentConfig();
050:                envConfig.setTransactional(true);
051:                envConfig.setAllowCreate(true);
052:                env = new Environment(new File(homeDirectory), envConfig);
053:
054:                // Set the Berkeley DB config for opening all stores.
055:                //
056:                DatabaseConfig dbConfig = new DatabaseConfig();
057:                dbConfig.setTransactional(true);
058:                dbConfig.setAllowCreate(true);
059:
060:                // Create the Serial class catalog.  This holds the serialized class
061:                // format for all database records of serial format.
062:                //
063:                Database catalogDb = env.openDatabase(null, CLASS_CATALOG,
064:                        dbConfig);
065:                javaCatalog = new StoredClassCatalog(catalogDb);
066:
067:                // Open the Berkeley DB database for the part, supplier and shipment
068:                // stores.  The stores are opened with no duplicate keys allowed.
069:                //
070:                partDb = env.openDatabase(null, PART_STORE, dbConfig);
071:
072:                supplierDb = env.openDatabase(null, SUPPLIER_STORE, dbConfig);
073:
074:                shipmentDb = env.openDatabase(null, SHIPMENT_STORE, dbConfig);
075:            }
076:
077:            /**
078:             * Return the storage environment for the database.
079:             */
080:            public final Environment getEnvironment() {
081:
082:                return env;
083:            }
084:
085:            /**
086:             * Return the class catalog.
087:             */
088:            public final StoredClassCatalog getClassCatalog() {
089:
090:                return javaCatalog;
091:            }
092:
093:            /**
094:             * Return the part storage container.
095:             */
096:            public final Database getPartDatabase() {
097:
098:                return partDb;
099:            }
100:
101:            /**
102:             * Return the supplier storage container.
103:             */
104:            public final Database getSupplierDatabase() {
105:
106:                return supplierDb;
107:            }
108:
109:            /**
110:             * Return the shipment storage container.
111:             */
112:            public final Database getShipmentDatabase() {
113:
114:                return shipmentDb;
115:            }
116:
117:            /**
118:             * Close all databases and the environment.
119:             */
120:            public void close() throws DatabaseException {
121:
122:                partDb.close();
123:                supplierDb.close();
124:                shipmentDb.close();
125:                // And don't forget to close the catalog and the environment.
126:                javaCatalog.close();
127:                env.close();
128:            }
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.