Source Code Cross Referenced for ConnectionWrapper.java in  » Forum » mvnforum-1.1 » net » myvietnam » mvncore » db » 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 » Forum » mvnforum 1.1 » net.myvietnam.mvncore.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/db/ConnectionWrapper.java,v 1.6 2007/09/26 04:11:07 minhnn Exp $
003:         * $Author: minhnn $
004:         * $Revision: 1.6 $
005:         * $Date: 2007/09/26 04:11:07 $
006:         *
007:         * ====================================================================
008:         *
009:         * Copyright (C) 2002-2007 by MyVietnam.net
010:         *
011:         * All copyright notices regarding MyVietnam and MyVietnam CoreLib
012:         * MUST remain intact in the scripts and source code.
013:         *
014:         * This library is free software; you can redistribute it and/or
015:         * modify it under the terms of the GNU Lesser General Public
016:         * License as published by the Free Software Foundation; either
017:         * version 2.1 of the License, or (at your option) any later version.
018:         *
019:         * This library is distributed in the hope that it will be useful,
020:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
021:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
022:         * Lesser General Public License for more details.
023:         *
024:         * You should have received a copy of the GNU Lesser General Public
025:         * License along with this library; if not, write to the Free Software
026:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
027:         *
028:         * Correspondence and Marketing Questions can be sent to:
029:         * info at MyVietnam net
030:         *
031:         * @author: Minh Nguyen  
032:         */
033:        package net.myvietnam.mvncore.db;
034:
035:        import java.sql.*;
036:        import java.util.Map;
037:        import java.util.Properties;
038:
039:        import org.apache.commons.lang.NotImplementedException;
040:
041:        public class ConnectionWrapper implements  Connection {
042:
043:            private DBConnectionManager connectionManager = null;
044:
045:            private static int outsideConnection = 0;
046:
047:            Connection delegate = null;
048:
049:            ConnectionWrapper(Connection original,
050:                    DBConnectionManager conManager) {
051:                if (original == null) {
052:                    throw new IllegalArgumentException(
053:                            "Cannot accept the connection is null.");
054:                }
055:                if (conManager == null) {
056:                    throw new IllegalArgumentException(
057:                            "Cannot accept the DBConnectionManager is null.");
058:                }
059:                delegate = original;
060:                connectionManager = conManager;
061:                outsideConnection++;
062:            }
063:
064:            private void makeSureNotClose() {
065:                if (delegate == null) {
066:                    throw new IllegalStateException(
067:                            "Connection has been closed (delegate == null).");
068:                }
069:            }
070:
071:            public void close() throws SQLException {
072:                //delegate.close();
073:                if (delegate != null) {
074:                    connectionManager.freeConnection(delegate);
075:                    delegate = null;
076:                    outsideConnection--;
077:                }
078:            }
079:
080:            public void clearWarnings() throws SQLException {
081:                makeSureNotClose();
082:                delegate.clearWarnings();
083:            }
084:
085:            public void commit() throws SQLException {
086:                makeSureNotClose();
087:                delegate.commit();
088:            }
089:
090:            public Statement createStatement() throws SQLException {
091:                makeSureNotClose();
092:                return delegate.createStatement();
093:            }
094:
095:            public Statement createStatement(int resultSetType,
096:                    int resultSetConcurrency, int resultSetHoldability)
097:                    throws SQLException {
098:                makeSureNotClose();
099:                return delegate.createStatement(resultSetType,
100:                        resultSetConcurrency, resultSetHoldability);
101:            }
102:
103:            public Statement createStatement(int resultSetType,
104:                    int resultSetConcurrency) throws SQLException {
105:                makeSureNotClose();
106:                return delegate.createStatement(resultSetType,
107:                        resultSetConcurrency);
108:            }
109:
110:            public boolean getAutoCommit() throws SQLException {
111:                makeSureNotClose();
112:                return delegate.getAutoCommit();
113:            }
114:
115:            public String getCatalog() throws SQLException {
116:                makeSureNotClose();
117:                return delegate.getCatalog();
118:            }
119:
120:            public int getHoldability() throws SQLException {
121:                makeSureNotClose();
122:                return delegate.getHoldability();
123:            }
124:
125:            public DatabaseMetaData getMetaData() throws SQLException {
126:                makeSureNotClose();
127:                return delegate.getMetaData();
128:            }
129:
130:            public int getTransactionIsolation() throws SQLException {
131:                makeSureNotClose();
132:                return delegate.getTransactionIsolation();
133:            }
134:
135:            public Map getTypeMap() throws SQLException {
136:                makeSureNotClose();
137:                return delegate.getTypeMap();
138:            }
139:
140:            public SQLWarning getWarnings() throws SQLException {
141:                makeSureNotClose();
142:                return delegate.getWarnings();
143:            }
144:
145:            public boolean isClosed() throws SQLException {
146:                makeSureNotClose();
147:                return delegate.isClosed();
148:            }
149:
150:            public boolean isReadOnly() throws SQLException {
151:                makeSureNotClose();
152:                return delegate.isReadOnly();
153:            }
154:
155:            public String nativeSQL(String sql) throws SQLException {
156:                makeSureNotClose();
157:                return delegate.nativeSQL(sql);
158:            }
159:
160:            public CallableStatement prepareCall(String sql, int resultSetType,
161:                    int resultSetConcurrency, int resultSetHoldability)
162:                    throws SQLException {
163:                makeSureNotClose();
164:                return delegate.prepareCall(sql, resultSetType,
165:                        resultSetConcurrency, resultSetHoldability);
166:            }
167:
168:            public CallableStatement prepareCall(String sql, int resultSetType,
169:                    int resultSetConcurrency) throws SQLException {
170:                makeSureNotClose();
171:                return delegate.prepareCall(sql, resultSetType,
172:                        resultSetConcurrency);
173:            }
174:
175:            public CallableStatement prepareCall(String sql)
176:                    throws SQLException {
177:                makeSureNotClose();
178:                return delegate.prepareCall(sql);
179:            }
180:
181:            public PreparedStatement prepareStatement(String sql,
182:                    int resultSetType, int resultSetConcurrency,
183:                    int resultSetHoldability) throws SQLException {
184:                makeSureNotClose();
185:                return delegate.prepareStatement(sql, resultSetType,
186:                        resultSetConcurrency, resultSetHoldability);
187:            }
188:
189:            public PreparedStatement prepareStatement(String sql,
190:                    int resultSetType, int resultSetConcurrency)
191:                    throws SQLException {
192:                makeSureNotClose();
193:                return delegate.prepareStatement(sql, resultSetType,
194:                        resultSetConcurrency);
195:            }
196:
197:            public PreparedStatement prepareStatement(String sql,
198:                    int autoGeneratedKeys) throws SQLException {
199:                makeSureNotClose();
200:                return delegate.prepareStatement(sql, autoGeneratedKeys);
201:            }
202:
203:            public PreparedStatement prepareStatement(String sql,
204:                    int[] columnIndexes) throws SQLException {
205:                makeSureNotClose();
206:                return delegate.prepareStatement(sql, columnIndexes);
207:            }
208:
209:            public PreparedStatement prepareStatement(String sql,
210:                    String[] columnNames) throws SQLException {
211:                makeSureNotClose();
212:                return delegate.prepareStatement(sql, columnNames);
213:            }
214:
215:            public PreparedStatement prepareStatement(String sql)
216:                    throws SQLException {
217:                makeSureNotClose();
218:                return delegate.prepareStatement(sql);
219:            }
220:
221:            public void releaseSavepoint(Savepoint savepoint)
222:                    throws SQLException {
223:                makeSureNotClose();
224:                delegate.releaseSavepoint(savepoint);
225:            }
226:
227:            public void rollback() throws SQLException {
228:                makeSureNotClose();
229:                delegate.rollback();
230:            }
231:
232:            public void rollback(Savepoint savepoint) throws SQLException {
233:                makeSureNotClose();
234:                delegate.rollback(savepoint);
235:            }
236:
237:            public void setAutoCommit(boolean autoCommit) throws SQLException {
238:                makeSureNotClose();
239:                delegate.setAutoCommit(autoCommit);
240:            }
241:
242:            public void setCatalog(String catalog) throws SQLException {
243:                makeSureNotClose();
244:                delegate.setCatalog(catalog);
245:            }
246:
247:            public void setHoldability(int holdability) throws SQLException {
248:                makeSureNotClose();
249:                delegate.setHoldability(holdability);
250:            }
251:
252:            public void setReadOnly(boolean readOnly) throws SQLException {
253:                makeSureNotClose();
254:                delegate.setReadOnly(readOnly);
255:            }
256:
257:            public Savepoint setSavepoint() throws SQLException {
258:                makeSureNotClose();
259:                return delegate.setSavepoint();
260:            }
261:
262:            public Savepoint setSavepoint(String name) throws SQLException {
263:                makeSureNotClose();
264:                return delegate.setSavepoint(name);
265:            }
266:
267:            public void setTransactionIsolation(int level) throws SQLException {
268:                makeSureNotClose();
269:                delegate.setTransactionIsolation(level);
270:            }
271:
272:            public void setTypeMap(Map map) throws SQLException {
273:                makeSureNotClose();
274:                delegate.setTypeMap(map);
275:            }
276:
277:            public Array createArrayOf(String typeName, Object[] elements)
278:                    throws SQLException {
279:                throw new NotImplementedException("createArrayOf");
280:            }
281:
282:            public Blob createBlob() throws SQLException {
283:                throw new NotImplementedException("createBlob");
284:            }
285:
286:            public Clob createClob() throws SQLException {
287:                throw new NotImplementedException("createClob");
288:            }
289:
290:            public NClob createNClob() throws SQLException {
291:                throw new NotImplementedException("createNClob");
292:            }
293:
294:            public SQLXML createSQLXML() throws SQLException {
295:                throw new NotImplementedException("createSQLXML");
296:            }
297:
298:            public Struct createStruct(String typeName, Object[] attributes)
299:                    throws SQLException {
300:                throw new NotImplementedException("createStruct");
301:            }
302:
303:            public Properties getClientInfo() throws SQLException {
304:                throw new NotImplementedException("getClientInfo");
305:            }
306:
307:            public String getClientInfo(String name) throws SQLException {
308:                throw new NotImplementedException("getClientInfo");
309:            }
310:
311:            public boolean isValid(int timeout) throws SQLException {
312:                throw new NotImplementedException("isValid");
313:            }
314:
315:            public void setClientInfo(Properties properties)
316:                    throws SQLClientInfoException {
317:                throw new NotImplementedException("setClientInfo");
318:            }
319:
320:            public void setClientInfo(String name, String value)
321:                    throws SQLClientInfoException {
322:                throw new NotImplementedException("setClientInfo");
323:            }
324:
325:            public boolean isWrapperFor(Class iface) throws SQLException {
326:                throw new NotImplementedException("isWrapperFor");
327:            }
328:
329:            public Object unwrap(Class iface) throws SQLException {
330:                throw new NotImplementedException("unwrap");
331:            }
332:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.