Source Code Cross Referenced for DBFactory.java in  » Database-ORM » Torque » org » apache » torque » adapter » 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 » Torque » org.apache.torque.adapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.torque.adapter;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with 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,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.HashMap;
023:        import java.util.Map;
024:
025:        /**
026:         * This class creates different {@link org.apache.torque.adapter.DB}
027:         * objects based on specified JDBC driver name.
028:         *
029:         * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
030:         * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
031:         * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
032:         * @author <a href="mailto:ralf@reswi.ruhr.de">Ralf Stranzenbach</a>
033:         * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
034:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
035:         * @version $Id: DBFactory.java 476550 2006-11-18 16:08:37Z tfischer $
036:         */
037:        public class DBFactory {
038:            /**
039:             * JDBC driver to Torque Adapter map.
040:             */
041:            private static Map adapters = new HashMap(40);
042:
043:            /**
044:             * Initialize the JDBC driver to Torque Adapter map.
045:             */
046:            static {
047:                adapters.put("com.ibm.as400.access.AS400JDBCDriver",
048:                        DBDB2400.class);
049:                adapters.put("COM.ibm.db2.jdbc.app.DB2Driver", DBDB2App.class);
050:                adapters.put("COM.ibm.db2.jdbc.net.DB2Driver", DBDB2Net.class);
051:                adapters.put("COM.cloudscape.core.JDBCDriver",
052:                        DBCloudscape.class);
053:                adapters.put("org.firebirdsql.jdbc.FBDriver", DBFirebird.class);
054:                adapters.put("org.hsql.jdbcDriver", DBHypersonicSQL.class);
055:                adapters.put("org.hsqldb.jdbcDriver", DBHypersonicSQL.class);
056:                adapters.put("interbase.interclient.Driver", DBInterbase.class);
057:                adapters.put("org.enhydra.instantdb.jdbc.idbDriver",
058:                        DBInstantDB.class);
059:                adapters.put("com.microsoft.jdbc.sqlserver.SQLServerDriver",
060:                        DBMSSQL.class);
061:                adapters.put("com.jnetdirect.jsql.JSQLDriver", DBMSSQL.class);
062:                adapters.put("org.gjt.mm.mysql.Driver", DBMM.class);
063:                adapters.put("oracle.jdbc.driver.OracleDriver", DBOracle.class);
064:                adapters.put("org.postgresql.Driver", DBPostgres.class);
065:                adapters.put("com.sap.dbtech.jdbc.DriverSapDB", DBSapDB.class);
066:                adapters.put("com.sybase.jdbc.SybDriver", DBSybase.class);
067:                adapters.put("com.sybase.jdbc2.jdbc.SybDriver", DBSybase.class);
068:                adapters.put("weblogic.jdbc.pool.Driver", DBWeblogic.class);
069:                adapters.put("org.axiondb.jdbc.AxionDriver", DBAxion.class);
070:                adapters.put("com.informix.jdbc.IfxDriver", DBInformix.class);
071:                adapters.put("sun.jdbc.odbc.JdbcOdbcDriver", DBOdbc.class);
072:
073:                adapters.put("com.ibm.db2.jcc.DB2Driver", DBDerby.class);
074:                adapters.put("org.apache.derby.jdbc.EmbeddedDriver",
075:                        DBDerby.class);
076:
077:                // add some short names to be used when drivers are not used
078:                adapters.put("as400", DBDB2400.class);
079:                adapters.put("db2app", DBDB2App.class);
080:                adapters.put("db2net", DBDB2Net.class);
081:                adapters.put("cloudscape", DBCloudscape.class);
082:                adapters.put("firebird", DBFirebird.class);
083:                adapters.put("hypersonic", DBHypersonicSQL.class);
084:                adapters.put("interbase", DBInterbase.class);
085:                adapters.put("instantdb", DBInstantDB.class);
086:                adapters.put("mssql", DBMSSQL.class);
087:                adapters.put("mysql", DBMM.class);
088:                adapters.put("oracle", DBOracle.class);
089:                adapters.put("postgresql", DBPostgres.class);
090:                adapters.put("sapdb", DBSapDB.class);
091:                adapters.put("sybase", DBSybase.class);
092:                adapters.put("weblogic", DBWeblogic.class);
093:                adapters.put("axion", DBAxion.class);
094:                adapters.put("informix", DBInformix.class);
095:                adapters.put("odbc", DBOdbc.class);
096:                adapters.put("msaccess", DBOdbc.class);
097:
098:                adapters.put("derby", DBDerby.class);
099:
100:                adapters.put("", DBNone.class);
101:            }
102:
103:            /**
104:             * Private constructor to prevent instantiation.
105:             *
106:             * Class contains only static methods, so no instances are needed.
107:             */
108:            private DBFactory() {
109:            }
110:
111:            /**
112:             * Creates a new instance of the Torque database adapter associated
113:             * with the specified JDBC driver or adapter key.
114:             *
115:             * @param key The fully-qualified name of the JDBC driver
116:             *        or a shorter form adapter key.
117:             * @return An instance of a Torque database adapter, or null if
118:             *         no adapter exists for the given key.
119:             * @throws InstantiationException throws if the adapter could not be
120:             *         instantiated
121:             */
122:            public static DB create(String key) throws InstantiationException {
123:                Class adapterClass = (Class) adapters.get(key);
124:
125:                if (adapterClass == null) {
126:                    return null;
127:                }
128:
129:                try {
130:                    DB adapter = (DB) adapterClass.newInstance();
131:                    // adapter.setJDBCDriver(driver);
132:                    return adapter;
133:                } catch (IllegalAccessException e) {
134:                    throw new InstantiationException(
135:                            "Could not instantiate adapter for key : "
136:                                    + key
137:                                    + ": Assure that adapter classes are in your classpath");
138:                }
139:            }
140:
141:            /**
142:             * Creates a new instance of the Torque database adapter associated
143:             * with the specified JDBC driver or adapter key and the class defined.
144:             *
145:             * @param key The fully-qualified name of the JDBC driver
146:             *        or a shorter form adapter key.
147:             * @param className The fully qualified name of the adapter class
148:             * @return An instance of a Torque database adapter.
149:             * @throws InstantiationException throws if the adapter could not be
150:             *         instantiated
151:             */
152:            public static DB create(String key, String className)
153:                    throws InstantiationException {
154:                Class adapterClass;
155:
156:                try {
157:                    adapterClass = (Class) Class.forName(className);
158:                } catch (ClassNotFoundException e) {
159:                    throw new InstantiationException("Could not find adapter "
160:                            + className + " for key " + key
161:                            + ": Check your configuration file");
162:                }
163:
164:                try {
165:                    DB adapter = (DB) adapterClass.newInstance();
166:                    adapters.put(key, adapterClass);
167:                    // adapter.setJDBCDriver(driver);
168:                    return adapter;
169:                } catch (IllegalAccessException e) {
170:                    throw new InstantiationException(
171:                            "Could not instantiate adapter for key: "
172:                                    + key
173:                                    + ": Assure that adapter classes are in your classpath");
174:                }
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.