Source Code Cross Referenced for EmbeddedDriver.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » jdbc » 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 » db derby 10.2 » org.apache.derby.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.jdbc.EmbeddedDriver
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to You under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.jdbc;
023:
024:        import java.sql.DriverManager;
025:        import java.sql.Driver;
026:        import java.sql.Connection;
027:        import java.sql.DriverPropertyInfo;
028:        import java.sql.SQLException;
029:
030:        import java.io.PrintStream;
031:        import java.util.Properties;
032:
033:        import org.apache.derby.iapi.reference.MessageId;
034:        import org.apache.derby.iapi.reference.Attribute;
035:        import org.apache.derby.iapi.services.i18n.MessageService;
036:        import org.apache.derby.iapi.jdbc.JDBCBoot;
037:
038:        /**
039:         The embedded JDBC driver (Type 4) for Derby.
040:         <P>
041:         The driver automatically supports the correct JDBC specification version
042:         for the Java Virtual Machine's environment.
043:         <UL>
044:         <LI> JDBC 4.0 - Java SE 6
045:         <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
046:         <LI> JDBC 2.0 - Java 2 - JDK 1.2,1.3
047:         </UL>
048:
049:         <P>
050:         Loading this JDBC driver boots the database engine
051:         within the same Java virtual machine.
052:         <P>
053:         The correct code to load the Derby engine using this driver is
054:         (with approriate try/catch blocks):
055:         <PRE>
056:         Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
057:
058:         // or
059:
060:         new org.apache.derby.jdbc.EmbeddedDriver();
061:
062:        
063:         </PRE>
064:         When loaded in this way, the class boots the actual JDBC driver indirectly.
065:         The JDBC specification recommends the Class.ForName method without the .newInstance()
066:         method call, but adding the newInstance() guarantees
067:         that Derby will be booted on any Java Virtual Machine.
068:
069:         <P>
070:         Note that you do not need to manually load the driver this way if you are
071:         running on Jave SE 6 or later. In that environment, the driver will be
072:         automatically loaded for you when your application requests a connection to
073:         a Derby database.
074:         <P>
075:         Any initial error messages are placed in the PrintStream
076:         supplied by the DriverManager. If the PrintStream is null error messages are
077:         sent to System.err. Once the Derby engine has set up an error
078:         logging facility (by default to derby.log) all subsequent messages are sent to it.
079:         <P>
080:         By convention, the class used in the Class.forName() method to
081:         boot a JDBC driver implements java.sql.Driver.
082:
083:         This class is not the actual JDBC driver that gets registered with
084:         the Driver Manager. It proxies requests to the registered Derby JDBC driver.
085:
086:         @see java.sql.DriverManager
087:         @see java.sql.DriverManager#getLogStream
088:         @see java.sql.Driver
089:         @see java.sql.SQLException
090:         */
091:
092:        public class EmbeddedDriver implements  Driver {
093:
094:            static {
095:
096:                EmbeddedDriver.boot();
097:            }
098:
099:            private AutoloadedDriver _autoloadedDriver;
100:
101:            // Boot from the constructor as well to ensure that
102:            // Class.forName(...).newInstance() reboots Derby 
103:            // after a shutdown inside the same JVM.
104:            public EmbeddedDriver() {
105:                EmbeddedDriver.boot();
106:            }
107:
108:            /*
109:             ** Methods from java.sql.Driver.
110:             */
111:            /**
112:            	Accept anything that starts with <CODE>jdbc:derby:</CODE>.
113:            	@exception SQLException if a database-access error occurs.
114:            @see java.sql.Driver
115:             */
116:            public boolean acceptsURL(String url) throws SQLException {
117:                return getDriverModule().acceptsURL(url);
118:            }
119:
120:            /**
121:            	Connect to the URL if possible
122:            	@exception SQLException illegal url or problem with connectiong
123:            @see java.sql.Driver
124:             */
125:            public Connection connect(String url, Properties info)
126:                    throws SQLException {
127:                return getDriverModule().connect(url, info);
128:            }
129:
130:            /**
131:             * Returns an array of DriverPropertyInfo objects describing possible properties.
132:              @exception SQLException if a database-access error occurs.
133:              @see java.sql.Driver
134:             */
135:            public DriverPropertyInfo[] getPropertyInfo(String url,
136:                    Properties info) throws SQLException {
137:                return getDriverModule().getPropertyInfo(url, info);
138:            }
139:
140:            /**
141:             * Returns the driver's major version number. 
142:             @see java.sql.Driver
143:             */
144:            public int getMajorVersion() {
145:                try {
146:                    return (getDriverModule().getMajorVersion());
147:                } catch (SQLException se) {
148:                    return 0;
149:                }
150:            }
151:
152:            /**
153:             * Returns the driver's minor version number.
154:             @see java.sql.Driver
155:             */
156:            public int getMinorVersion() {
157:                try {
158:                    return (getDriverModule().getMinorVersion());
159:                } catch (SQLException se) {
160:                    return 0;
161:                }
162:            }
163:
164:            /**
165:             * Report whether the Driver is a genuine JDBC COMPLIANT (tm) driver.
166:               @see java.sql.Driver
167:             */
168:            public boolean jdbcCompliant() {
169:                try {
170:                    return (getDriverModule().jdbcCompliant());
171:                } catch (SQLException se) {
172:                    return false;
173:                }
174:            }
175:
176:            /**
177:             * Lookup the booted driver module appropriate to our JDBC level.
178:             */
179:            private Driver getDriverModule() throws SQLException {
180:                return AutoloadedDriver.getDriverModule();
181:            }
182:
183:            /*
184:             ** Find the appropriate driver for our JDBC level and boot it.
185:             *  This is package protected so that AutoloadedDriver can call it.
186:             */
187:            static void boot() {
188:                PrintStream ps = DriverManager.getLogStream();
189:
190:                if (ps == null)
191:                    ps = System.err;
192:
193:                new JDBCBoot().boot(Attribute.PROTOCOL, ps);
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.