Source Code Cross Referenced for Constructors.java in  » Database-JDBC-Connection-Pool » octopus » com » internetcds » jdbc » tds » 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 JDBC Connection Pool » octopus » com.internetcds.jdbc.tds 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // Copyright 1999 Craig Spannring
003:        //
004:        // All rights reserved.
005:        //
006:        // Redistribution and use in source and binary forms, with or without
007:        // modification, are permitted provided that the following conditions are met:
008:        // 1. Redistributions of source code must retain the above copyright
009:        //    notice, this list of conditions and the following disclaimer.
010:        // 2. Redistributions in binary form must reproduce the above copyright
011:        //    notice, this list of conditions and the following disclaimer in the
012:        //    documentation and/or other materials provided with the distribution.
013:        // 3. All advertising materials mentioning features or use of this software
014:        //    must display the following acknowledgement:
015:        //      This product includes software developed by Craig Spannring
016:        // 4. The name of Craig Spannring may not be used to endorse or promote
017:        //    products derived from this software without specific prior
018:        //    written permission.
019:        //
020:        // THIS SOFTWARE IS PROVIDED BY CRAIG SPANNRING ``AS IS'' AND
021:        // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
022:        // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
023:        // ARE DISCLAIMED.  IN NO EVENT SHALL CRAIG SPANNRING BE LIABLE
024:        // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
025:        // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
026:        // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
027:        // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
028:        // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
029:        // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
030:        // SUCH DAMAGE.
031:        //
032:
033:        package com.internetcds.jdbc.tds;
034:
035:        public class Constructors {
036:            public static final String cvsVersion = "$Id: Constructors.java,v 1.2 2007-10-19 13:21:40 sinisa Exp $";
037:
038:            static boolean dejavu = false;
039:
040:            static final int JDBC2_0 = 2;
041:            static final int JDBC1_0 = 1;
042:
043:            private static int jdbcVersion = JDBC1_0;
044:            private static String jdbcVersionName = null;
045:
046:            private static java.lang.reflect.Constructor resultSetCtor = null;
047:            private static java.lang.reflect.Constructor preparedStatementCtor = null;
048:            private static java.lang.reflect.Constructor callableStatementCtor = null;
049:            private static java.lang.reflect.Constructor connectionCtor = null;
050:
051:            static private java.lang.reflect.Constructor getCtor(
052:                    String classNamePrefix, Class paramTypes[])
053:                    throws java.lang.ClassNotFoundException,
054:                    java.lang.NoSuchMethodException {
055:                java.lang.reflect.Constructor result = null;
056:                String className = null;
057:                Class theClass = null;
058:
059:                className = (classNamePrefix + "_" + jdbcVersionName);
060:                theClass = java.lang.Class.forName(className);
061:
062:                result = theClass.getConstructor(paramTypes);
063:
064:                return result;
065:            } /* getCtor()  */
066:
067:            static private void init() throws java.sql.SQLException {
068:                try {
069:                    Class resultSetParamTypes[] = {
070:                            java.lang.Class
071:                                    .forName("com.internetcds.jdbc.tds.Tds"),
072:                            java.lang.Class
073:                                    .forName("com.internetcds.jdbc.tds.Statement"),
074:                            java.lang.Class
075:                                    .forName("com.internetcds.jdbc.tds.Columns") };
076:                    Class preparedStatementParamTypes[] = {
077:                            java.lang.Class.forName("java.sql.Connection"),
078:                            java.lang.Class
079:                                    .forName("com.internetcds.jdbc.tds.Tds"),
080:                            java.lang.Class.forName("java.lang.String") };
081:                    Class callableStatementParamTypes[] = {
082:                            java.lang.Class.forName("java.sql.Connection"),
083:                            java.lang.Class
084:                                    .forName("com.internetcds.jdbc.tds.Tds"),
085:                            java.lang.Class.forName("java.lang.String") };
086:                    Class connectionParamTypes[] = { java.lang.Class
087:                            .forName("java.util.Properties") };
088:
089:                    try {
090:                        Class statement = java.lang.Class
091:                                .forName("java.sql.Statement");
092:                        java.lang.reflect.Method execBatch = statement
093:                                .getDeclaredMethod("executeBatch", new Class[0]);
094:
095:                        jdbcVersion = JDBC2_0;
096:                        jdbcVersionName = "2_0";
097:                    } catch (NoSuchMethodException nsme) {
098:                        jdbcVersion = JDBC1_0;
099:                        jdbcVersionName = "1_0";
100:                    }
101:
102:                    try {
103:                        resultSetCtor = getCtor(
104:                                "com.internetcds.jdbc.tds.ResultSet",
105:                                resultSetParamTypes);
106:                        preparedStatementCtor = getCtor(
107:                                "com.internetcds.jdbc.tds.PreparedStatement",
108:                                preparedStatementParamTypes);
109:                        callableStatementCtor = getCtor(
110:                                "com.internetcds.jdbc.tds.CallableStatement",
111:                                callableStatementParamTypes);
112:                        connectionCtor = getCtor(
113:                                "com.internetcds.jdbc.tds.Connection",
114:                                connectionParamTypes);
115:                    } catch (java.lang.ClassNotFoundException e) {
116:                        if (jdbcVersion == JDBC2_0) {
117:                            // 
118:                            // If we couldn't find the 2.0 classes, let's try to fall back 
119:                            // to JDBC 1.0
120:                            //
121:                            jdbcVersion = JDBC1_0;
122:                            jdbcVersionName = "1_0";
123:                            resultSetCtor = getCtor(
124:                                    "com.internetcds.jdbc.tds.ResultSet",
125:                                    resultSetParamTypes);
126:                            preparedStatementCtor = getCtor(
127:                                    "com.internetcds.jdbc.tds.PreparedStatement",
128:                                    preparedStatementParamTypes);
129:                            callableStatementCtor = getCtor(
130:                                    "com.internetcds.jdbc.tds.CallableStatement",
131:                                    callableStatementParamTypes);
132:                            connectionCtor = getCtor(
133:                                    "com.internetcds.jdbc.tds.Connection",
134:                                    connectionParamTypes);
135:                        }
136:                    }
137:                } catch (java.lang.ClassNotFoundException e) {
138:                    System.err.println("Couldn't find the class"); // XXX remove println
139:                    throw new java.sql.SQLException(e.getMessage());
140:                } catch (java.lang.NoSuchMethodException e) {
141:                    System.err.println("Couldn't find a constructor");
142:                    throw new java.sql.SQLException(e.getMessage());
143:                }
144:
145:                dejavu = true;
146:            } /* init()  */
147:
148:            public static java.sql.ResultSet newResultSet(Tds tds_,
149:                    java.sql.Statement stmt_, Columns columns_)
150:                    throws java.sql.SQLException {
151:                if (!dejavu) {
152:                    init();
153:                }
154:
155:                java.sql.ResultSet result = null;
156:                try {
157:                    Object params[] = { tds_, stmt_, columns_ };
158:
159:                    result = (java.sql.ResultSet) resultSetCtor
160:                            .newInstance(params);
161:                } catch (java.lang.reflect.InvocationTargetException e) {
162:                    throw new java.sql.SQLException(e.getTargetException()
163:                            .getMessage());
164:                } catch (Throwable e) {
165:                    e.printStackTrace();
166:                    throw new java.sql.SQLException(e.getMessage());
167:                }
168:                return result;
169:            }
170:
171:            public static java.sql.CallableStatement newCallableStatement(
172:                    Object cx_, com.internetcds.jdbc.tds.Tds tds_,
173:                    java.lang.String sql_) throws java.sql.SQLException {
174:                if (!dejavu) {
175:                    init();
176:                }
177:
178:                try {
179:                    Object params[] = { cx_, tds_, sql_ };
180:
181:                    return (java.sql.CallableStatement) callableStatementCtor
182:                            .newInstance(params);
183:                } catch (java.lang.reflect.InvocationTargetException e) {
184:                    throw new java.sql.SQLException(e.getTargetException()
185:                            .getMessage());
186:                } catch (Throwable e) {
187:                    throw new java.sql.SQLException(e.getMessage());
188:                }
189:            }
190:
191:            public static java.sql.PreparedStatement newPreparedStatement(
192:                    Object cx_, com.internetcds.jdbc.tds.Tds tds_,
193:                    java.lang.String sql_) throws java.sql.SQLException {
194:                if (!dejavu) {
195:                    init();
196:                }
197:
198:                try {
199:                    Object params[] = { cx_, tds_, sql_ };
200:
201:                    return (java.sql.PreparedStatement) preparedStatementCtor
202:                            .newInstance(params);
203:                } catch (java.lang.reflect.InvocationTargetException e) {
204:                    throw new java.sql.SQLException(e.getTargetException()
205:                            .getMessage());
206:                } catch (Throwable e) {
207:                    throw new java.sql.SQLException(e.getMessage());
208:                }
209:            }
210:
211:            public static java.sql.Connection newConnection(
212:                    java.util.Properties props_) throws java.sql.SQLException,
213:                    com.internetcds.jdbc.tds.TdsException {
214:                if (!dejavu) {
215:                    init();
216:                }
217:
218:                try {
219:                    Object params[] = { props_, };
220:
221:                    return (java.sql.Connection) connectionCtor
222:                            .newInstance(params);
223:                } catch (java.lang.reflect.InvocationTargetException e) {
224:                    throw new java.sql.SQLException(e.getTargetException()
225:                            .getMessage());
226:                } catch (Throwable e) {
227:                    throw new java.sql.SQLException(e.getMessage());
228:                }
229:            } /* newConnection()  */
230:
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.