Source Code Cross Referenced for PoolPreparedStatement.java in  » Database-JDBC-Connection-Pool » Primrose » uk » org » primrose » pool » core » 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 » Primrose » uk.org.primrose.pool.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *	Library name : Primrose - A Java Database Connection Pool.
003:         *	Published by Ben Keeping, http://primrose.org.uk .
004:         *	Copyright (C) 2004 Ben Keeping, primrose.org.uk
005:         *	Email: Use "Contact Us Form" on website
006:         *
007:         *	This library is free software; you can redistribute it and/or
008:         *	modify it under the terms of the GNU Lesser General Public
009:         *	License as published by the Free Software Foundation; either
010:         *	version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *	This library is distributed in the hope that it will be useful,
013:         *	but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *	Lesser General Public License for more details.
016:         *
017:         *	You should have received a copy of the GNU Lesser General Public
018:         *	License along with this library; if not, write to the Free Software
019:         *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */package uk.org.primrose.pool.core;
021:
022:        import java.math.BigDecimal;
023:        import java.util.Calendar;
024:        import java.sql.*;
025:
026:        /**
027:         * 	A wrapper for a vendor specific implementation of PreparedStatement.
028:         *	Allows for complete logging of SQL transactions, aswell as identifying
029:         *	unclosed statements before Connection close() calls.
030:         */
031:        public class PoolPreparedStatement extends PoolStatement implements 
032:                PreparedStatement {
033:            PreparedStatement ps = null;
034:
035:            public PoolPreparedStatement(PreparedStatement ps,
036:                    ConnectionHolder connHolder) {
037:                super (ps, connHolder);
038:                this .ps = ps;
039:            }
040:
041:            public PoolPreparedStatement() {
042:                super ();
043:            }
044:
045:            public ResultSet executeQuery() throws SQLException {
046:                if (this .connHolder.bDumpConnectionOnSQLException) {
047:                    try {
048:                        PoolResultSet prs = new PoolResultSet(
049:                                ps.executeQuery(), this .connHolder);
050:                        return prs;
051:                    } catch (SQLException sqle) {
052:                        this .connHolder.closeBehaviour = Pool.ON_CLOSE_SHOULD_DIE;
053:                        this .connHolder.logger
054:                                .warn("Closing connection due to SQLException on execute");
055:                        this .connHolder.myPool.notifyExceptionEvent();
056:                        throw sqle;
057:                    }
058:                } else {
059:                    PoolResultSet prs = new PoolResultSet(ps.executeQuery(),
060:                            this .connHolder);
061:                    return prs;
062:                }
063:
064:            }
065:
066:            public int executeUpdate() throws SQLException {
067:
068:                if (this .connHolder.bDumpConnectionOnSQLException) {
069:                    try {
070:                        return ps.executeUpdate();
071:                    } catch (SQLException sqle) {
072:                        this .connHolder.closeBehaviour = Pool.ON_CLOSE_SHOULD_DIE;
073:                        this .connHolder.logger
074:                                .warn("Closing connection due to SQLException on execute");
075:                        this .connHolder.myPool.notifyExceptionEvent();
076:                        throw sqle;
077:                    }
078:                } else {
079:                    return ps.executeUpdate();
080:                }
081:            }
082:
083:            public void setNull(int parameterIndex, int sqlType)
084:                    throws SQLException {
085:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
086:                        + sqlType + ")");
087:                ps.setNull(parameterIndex, sqlType);
088:            }
089:
090:            public void setBoolean(int parameterIndex, boolean x)
091:                    throws SQLException {
092:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
093:                        + x + ")");
094:                ps.setBoolean(parameterIndex, x);
095:            }
096:
097:            public void setByte(int parameterIndex, byte x) throws SQLException {
098:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
099:                        + x + ")");
100:                ps.setByte(parameterIndex, x);
101:            }
102:
103:            public void setShort(int parameterIndex, short x)
104:                    throws SQLException {
105:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
106:                        + x + ")");
107:                ps.setShort(parameterIndex, x);
108:            }
109:
110:            public void setInt(int parameterIndex, int x) throws SQLException {
111:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
112:                        + x + ")");
113:                ps.setInt(parameterIndex, x);
114:            }
115:
116:            public void setLong(int parameterIndex, long x) throws SQLException {
117:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
118:                        + x + ")");
119:                ps.setLong(parameterIndex, x);
120:            }
121:
122:            public void setFloat(int parameterIndex, float x)
123:                    throws SQLException {
124:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
125:                        + x + ")");
126:                ps.setFloat(parameterIndex, x);
127:            }
128:
129:            public void setDouble(int parameterIndex, double x)
130:                    throws SQLException {
131:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
132:                        + x + ")");
133:                ps.setDouble(parameterIndex, x);
134:            }
135:
136:            public void setBigDecimal(int parameterIndex, BigDecimal x)
137:                    throws SQLException {
138:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
139:                        + x + ")");
140:                ps.setBigDecimal(parameterIndex, x);
141:            }
142:
143:            public void setString(int parameterIndex, String x)
144:                    throws SQLException {
145:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
146:                        + x + ")");
147:                ps.setString(parameterIndex, x);
148:            }
149:
150:            public void setBytes(int parameterIndex, byte x[])
151:                    throws SQLException {
152:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
153:                        + x + ")");
154:                ps.setBytes(parameterIndex, x);
155:            }
156:
157:            public void setDate(int parameterIndex, java.sql.Date x)
158:                    throws SQLException {
159:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
160:                        + x + ")");
161:                ps.setDate(parameterIndex, x);
162:            }
163:
164:            public void setTime(int parameterIndex, java.sql.Time x)
165:                    throws SQLException {
166:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
167:                        + x + ")");
168:                ps.setTime(parameterIndex, x);
169:            }
170:
171:            public void setTimestamp(int parameterIndex, java.sql.Timestamp x)
172:                    throws SQLException {
173:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
174:                        + x + ")");
175:                ps.setTimestamp(parameterIndex, x);
176:            }
177:
178:            public void setAsciiStream(int parameterIndex,
179:                    java.io.InputStream x, int length) throws SQLException {
180:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
181:                        + x + ")");
182:                ps.setAsciiStream(parameterIndex, x, length);
183:            }
184:
185:            public void setUnicodeStream(int parameterIndex,
186:                    java.io.InputStream x, int length) throws SQLException {
187:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
188:                        + x + ")");
189:                ps.setUnicodeStream(parameterIndex, x, length);
190:            }
191:
192:            public void setBinaryStream(int parameterIndex,
193:                    java.io.InputStream x, int length) throws SQLException {
194:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
195:                        + x + ")");
196:                ps.setBinaryStream(parameterIndex, x, length);
197:            }
198:
199:            public void clearParameters() throws SQLException {
200:                ps.clearParameters();
201:            }
202:
203:            public void setObject(int parameterIndex, Object x,
204:                    int targetSqlType, int scale) throws SQLException {
205:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
206:                        + x + ")");
207:                ps.setObject(parameterIndex, x, targetSqlType, scale);
208:            }
209:
210:            public void setObject(int parameterIndex, Object x,
211:                    int targetSqlType) throws SQLException {
212:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
213:                        + x + ")");
214:                ps.setObject(parameterIndex, x, targetSqlType);
215:            }
216:
217:            public void setObject(int parameterIndex, Object x)
218:                    throws SQLException {
219:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
220:                        + x + ")");
221:                ps.setObject(parameterIndex, x);
222:            }
223:
224:            public boolean execute() throws SQLException {
225:                return ps.execute();
226:            }
227:
228:            public void addBatch() throws SQLException {
229:                ps.addBatch();
230:            }
231:
232:            public void setCharacterStream(int parameterIndex,
233:                    java.io.Reader reader, int length) throws SQLException {
234:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
235:                        + reader + ")");
236:                ps.setCharacterStream(parameterIndex, reader, length);
237:            }
238:
239:            public void setRef(int i, Ref x) throws SQLException {
240:                connHolder.sql = (connHolder.sql + " " + i + "(" + x + ")");
241:                ps.setRef(i, x);
242:            }
243:
244:            public void setBlob(int i, Blob x) throws SQLException {
245:                connHolder.sql = (connHolder.sql + " " + i + "(" + x + ")");
246:                ps.setBlob(i, x);
247:            }
248:
249:            public void setClob(int i, Clob x) throws SQLException {
250:                connHolder.sql = (connHolder.sql + " " + i + "(" + x + ")");
251:                ps.setClob(i, x);
252:            }
253:
254:            public void setArray(int i, Array x) throws SQLException {
255:                connHolder.sql = (connHolder.sql + " " + i + "(" + x + ")");
256:                ps.setArray(i, x);
257:            }
258:
259:            public ResultSetMetaData getMetaData() throws SQLException {
260:                return ps.getMetaData();
261:            }
262:
263:            public void setDate(int parameterIndex, java.sql.Date x,
264:                    Calendar cal) throws SQLException {
265:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
266:                        + x + ")");
267:                ps.setDate(parameterIndex, x, cal);
268:            }
269:
270:            public void setTime(int parameterIndex, java.sql.Time x,
271:                    Calendar cal) throws SQLException {
272:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
273:                        + x + ")");
274:                ps.setTime(parameterIndex, x, cal);
275:            }
276:
277:            public void setTimestamp(int parameterIndex, java.sql.Timestamp x,
278:                    Calendar cal) throws SQLException {
279:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
280:                        + x + ")");
281:                ps.setTimestamp(parameterIndex, x, cal);
282:            }
283:
284:            public void setNull(int parameterIndex, int sqlType, String typeName)
285:                    throws SQLException {
286:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
287:                        + typeName + ")");
288:                ps.setNull(parameterIndex, sqlType, typeName);
289:            }
290:
291:            public void setURL(int parameterIndex, java.net.URL x)
292:                    throws SQLException {
293:                connHolder.sql = (connHolder.sql + " " + parameterIndex + "("
294:                        + x + ")");
295:                ps.setURL(parameterIndex, x);
296:            }
297:
298:            public ParameterMetaData getParameterMetaData() throws SQLException {
299:                return ps.getParameterMetaData();
300:            }
301:
302:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.