Source Code Cross Referenced for LocalDatabase.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » 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 DBMS » Ozone 1.1 » org.ozoneDB 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Library License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: LocalDatabase.java,v 1.5 2002/07/29 11:30:23 per_nyfelt Exp $
008:
009:        package org.ozoneDB;
010:
011:        import java.io.*;
012:        import java.util.*;
013:        import org.ozoneDB.core.*;
014:        import org.ozoneDB.util.*;
015:        import org.ozoneDB.core.DbRemote.*;
016:        import org.ozoneDB.tools.*;
017:        import org.ozoneDB.DxLib.*;
018:
019:        /**
020:         * This class represents a local database server that runs inside the same
021:         * JVM as the client. For a detailed method description see OzoneInterface.
022:         * 
023:         * 
024:         * @author <a href="http://www.softwarebuero.de/">SMB</a>
025:         * @author <a href="http://www.medium.net/">SMB</a>
026:         * @version $Revision: 1.5 $Date: 2002/07/29 11:30:23 $
027:         * @see OzoneInterface
028:         */
029:        public final class LocalDatabase extends ExternalDatabase {
030:
031:            public Env theEnv;
032:
033:            public String userName;
034:
035:            public LocalDatabase() {
036:            }
037:
038:            /**
039:             * Create a new database in the given directory using default values
040:             * for all Setup entries.
041:             * 
042:             * 
043:             * @param _dirName
044:             * @return a StringWriter that holds the status messages
045:             * @exception java.lang.Exception
046:             * @see Setup
047:             */
048:            public synchronized String create(String dirName) throws Exception {
049:                //use default values
050:                Setup setup = new Setup(theEnv);
051:                return create(dirName, setup);
052:            }
053:
054:            /**
055:             * Create a new database in the given directory using the values
056:             * of the given Setup.
057:             *
058:             * @param dirName
059:             * @return a StringWriter that holds the status messages
060:             * @exception java.lang.Exception
061:             * @see Setup
062:             */
063:            public synchronized String create(String dirName, Setup setup)
064:                    throws Exception {
065:                StringWriter writer = new StringWriter();
066:                PrintWriter logFile = new PrintWriter(writer, true);
067:                Install.createDB(dirName, setup, logFile);
068:                return writer.toString();
069:            }
070:
071:            /** opens the database.
072:             * @param dirName is the path name of the database directory root
073:             */
074:            public void open(String dirName) throws Exception {
075:                String username = System.getProperty("user.name");
076:                open(dirName, null, username, username);
077:            }
078:
079:            /**
080:             *  For backwards compatibility
081:             *
082:             *  @deprecated but still needed by legacy software.
083:             *  use open(String _dirName, String _debugLevel ) instead.
084:             *  @param dirName is the path name of the database directory root
085:             *  @param debugLevel should match one of the constants in OzoneDebugLevel.
086:             *  Overrrides the property ozoneDB.logLevel in config.properties.
087:             */
088:            public void open(String dirName, int debugLevel) throws Exception {
089:                String level = OzoneDebugLevel.toLevel(debugLevel,
090:                        OzoneDebugLevel.INFO).toString();
091:                open(dirName, level);
092:            }
093:
094:            /**
095:             * Opens the database.
096:             * @param dirName is the path name of the database directory root
097:             * @param debugLevel derived from OzoneDebugLevel.
098:             * Overrrides the property ozoneDB.logLevel in config.properties. If set to null, the config.properties
099:             * setting will be used.
100:             */
101:            public void open(String dirName, String debugLevel)
102:                    throws Exception {
103:                String username = System.getProperty("user.name");
104:                open(dirName, debugLevel, username, username);
105:            }
106:
107:            /**
108:             * Opens the database.
109:             * @param dirName
110:             * @param debugLevel, one of the String constants in OzoneDebugLevel (e.g. INFO_STR).
111:             * Overrrides the property ozoneDB.logLevel in config.properties. If set to null, the config.properties
112:             * setting will be used.
113:             * @param userName
114:             * @param password
115:             */
116:            public void open(String dirName, String debugLevel,
117:                    String userName, String password) throws Exception {
118:                Hashtable props = new Hashtable();
119:                props.put(PROP_DIR, dirName);
120:                props.put(PROP_USER, userName);
121:                props.put(PROP_PASSWD, password);
122:                if (debugLevel != null) {
123:                    props.put(PROP_DEBUG, debugLevel);
124:                }
125:
126:                open(props);
127:            }
128:
129:            protected synchronized void open(Hashtable props) throws Exception {
130:                try {
131:                    super .open(props);
132:
133:                    String dirName = (String) props.get(PROP_DIR);
134:                    userName = (String) props.get(PROP_USER);
135:                    String passwd = (String) props.get(PROP_PASSWD);
136:                    String debugLevel = ((String) props.get(PROP_DEBUG));
137:
138:                    theEnv = new Env(dirName, debugLevel);
139:
140:                    // create the user if it doesn't exist yet; in local mode we cannot use
141:                    // the admin tool to do so
142:                    if (theEnv.userManager.userForName(userName) == null) {
143:                        theEnv.userManager.newUser(userName, userName
144:                                .hashCode());
145:                    }
146:                    theEnv.startDeadlockRecognition();
147:                } catch (Exception e) {
148:                    close();
149:                    throw e;
150:                }
151:            }
152:
153:            public boolean isOpen() throws Exception {
154:                return theEnv != null;
155:            }
156:
157:            public synchronized void close() throws Exception {
158:                super .close();
159:                if (theEnv != null) {
160:                    try {
161:                        theEnv.shutdown();
162:                    } finally {
163:                        theEnv = null;
164:                    }
165:                }
166:            }
167:
168:            protected DbClient newConnection() throws Exception {
169:                return new DbLocalClient(this , theEnv, userName);
170:            }
171:
172:            public String toString() {
173:                return "LocalDatabase";
174:            }
175:
176:            protected void finalize() throws Exception {
177:                close();
178:            }
179:
180:            /* Tells whether a database has been installed in the dbDir directory or not
181:             * useful for erver when starting up the ExternalDatabase and makes it possible to
182:             * determine whether to create or open a LocalDatabase
183:             */
184:            public boolean exists(String dbDir) {
185:                return Install.dbExists(dbDir);
186:            }
187:
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.