Source Code Cross Referenced for TesterStatement.java in  » Database-JDBC-Connection-Pool » Connection-Pool-DBCP » org » apache » commons » dbcp » 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 » Connection Pool DBCP » org.apache.commons.dbcp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.commons.dbcp;
019:
020:        import java.sql.Connection;
021:        import java.sql.ResultSet;
022:        import java.sql.SQLException;
023:        import java.sql.SQLWarning;
024:        import java.sql.Statement;
025:
026:        /**
027:         * A dummy {@link Statement}, for testing purposes.
028:         * 
029:         * @author Rodney Waldhoff
030:         * @author Dirk Verbeeck
031:         * @version $Revision: 479137 $ $Date: 2006-11-25 08:51:48 -0700 (Sat, 25 Nov 2006) $
032:         */
033:        public class TesterStatement implements  Statement {
034:            public TesterStatement(Connection conn) {
035:                _connection = conn;
036:            }
037:
038:            public TesterStatement(Connection conn, int resultSetType,
039:                    int resultSetConcurrency) {
040:                _connection = conn;
041:                _resultSetType = resultSetType;
042:                _resultSetConcurrency = resultSetConcurrency;
043:            }
044:
045:            protected Connection _connection = null;
046:            protected boolean _open = true;
047:            protected int _rowsUpdated = 1;
048:            protected boolean _executeResponse = true;
049:            protected int _maxFieldSize = 1024;
050:            protected int _maxRows = 1024;
051:            protected boolean _escapeProcessing = false;
052:            protected int _queryTimeout = 1000;
053:            protected String _cursorName = null;
054:            protected int _fetchDirection = 1;
055:            protected int _fetchSize = 1;
056:            protected int _resultSetConcurrency = 1;
057:            protected int _resultSetType = 1;
058:            protected ResultSet _resultSet = null;
059:
060:            public ResultSet executeQuery(String sql) throws SQLException {
061:                checkOpen();
062:                if ("null".equals(sql)) {
063:                    return null;
064:                }
065:                if ("invalid".equals(sql)) {
066:                    throw new SQLException("invalid query");
067:                }
068:                if ("broken".equals(sql)) {
069:                    throw new SQLException("broken connection");
070:                }
071:                if ("select username".equals(sql)) {
072:                    String username = ((TesterConnection) _connection)
073:                            .getUsername();
074:                    Object[][] data = { { username } };
075:                    return new TesterResultSet(this , data);
076:                } else {
077:                    return new TesterResultSet(this );
078:                }
079:            }
080:
081:            public int executeUpdate(String sql) throws SQLException {
082:                checkOpen();
083:                return _rowsUpdated;
084:            }
085:
086:            public void close() throws SQLException {
087:                checkOpen();
088:                _open = false;
089:                if (_resultSet != null) {
090:                    _resultSet.close();
091:                    _resultSet = null;
092:                }
093:            }
094:
095:            public int getMaxFieldSize() throws SQLException {
096:                checkOpen();
097:                return _maxFieldSize;
098:            }
099:
100:            public void setMaxFieldSize(int max) throws SQLException {
101:                checkOpen();
102:                _maxFieldSize = max;
103:            }
104:
105:            public int getMaxRows() throws SQLException {
106:                checkOpen();
107:                return _maxRows;
108:            }
109:
110:            public void setMaxRows(int max) throws SQLException {
111:                checkOpen();
112:                _maxRows = max;
113:            }
114:
115:            public void setEscapeProcessing(boolean enable) throws SQLException {
116:                checkOpen();
117:                _escapeProcessing = enable;
118:            }
119:
120:            public int getQueryTimeout() throws SQLException {
121:                checkOpen();
122:                return _queryTimeout;
123:            }
124:
125:            public void setQueryTimeout(int seconds) throws SQLException {
126:                checkOpen();
127:                _queryTimeout = seconds;
128:            }
129:
130:            public void cancel() throws SQLException {
131:                checkOpen();
132:            }
133:
134:            public SQLWarning getWarnings() throws SQLException {
135:                checkOpen();
136:                return null;
137:            }
138:
139:            public void clearWarnings() throws SQLException {
140:                checkOpen();
141:            }
142:
143:            public void setCursorName(String name) throws SQLException {
144:                checkOpen();
145:                _cursorName = name;
146:            }
147:
148:            public boolean execute(String sql) throws SQLException {
149:                checkOpen();
150:                return _executeResponse;
151:            }
152:
153:            public ResultSet getResultSet() throws SQLException {
154:                checkOpen();
155:                if (_resultSet == null) {
156:                    _resultSet = new TesterResultSet(this );
157:                }
158:                return _resultSet;
159:            }
160:
161:            public int getUpdateCount() throws SQLException {
162:                checkOpen();
163:                return _rowsUpdated;
164:            }
165:
166:            public boolean getMoreResults() throws SQLException {
167:                checkOpen();
168:                return false;
169:            }
170:
171:            public void setFetchDirection(int direction) throws SQLException {
172:                checkOpen();
173:                _fetchDirection = direction;
174:            }
175:
176:            public int getFetchDirection() throws SQLException {
177:                checkOpen();
178:                return _fetchDirection;
179:            }
180:
181:            public void setFetchSize(int rows) throws SQLException {
182:                checkOpen();
183:                _fetchSize = rows;
184:            }
185:
186:            public int getFetchSize() throws SQLException {
187:                checkOpen();
188:                return _fetchSize;
189:            }
190:
191:            public int getResultSetConcurrency() throws SQLException {
192:                checkOpen();
193:                return _resultSetConcurrency;
194:            }
195:
196:            public int getResultSetType() throws SQLException {
197:                checkOpen();
198:                return _resultSetType;
199:            }
200:
201:            public void addBatch(String sql) throws SQLException {
202:                checkOpen();
203:            }
204:
205:            public void clearBatch() throws SQLException {
206:                checkOpen();
207:            }
208:
209:            public int[] executeBatch() throws SQLException {
210:                checkOpen();
211:                return new int[0];
212:            }
213:
214:            public Connection getConnection() throws SQLException {
215:                checkOpen();
216:                return _connection;
217:            }
218:
219:            protected void checkOpen() throws SQLException {
220:                if (!_open) {
221:                    throw new SQLException("Connection is closed.");
222:                }
223:            }
224:
225:            // ------------------- JDBC 3.0 -----------------------------------------
226:            // Will be commented by the build process on a JDBC 2.0 system
227:
228:            /* JDBC_3_ANT_KEY_BEGIN */
229:            public boolean getMoreResults(int current) throws SQLException {
230:                throw new SQLException("Not implemented.");
231:            }
232:
233:            public ResultSet getGeneratedKeys() throws SQLException {
234:                throw new SQLException("Not implemented.");
235:            }
236:
237:            public int executeUpdate(String sql, int autoGeneratedKeys)
238:                    throws SQLException {
239:                throw new SQLException("Not implemented.");
240:            }
241:
242:            public int executeUpdate(String sql, int columnIndexes[])
243:                    throws SQLException {
244:                throw new SQLException("Not implemented.");
245:            }
246:
247:            public int executeUpdate(String sql, String columnNames[])
248:                    throws SQLException {
249:                throw new SQLException("Not implemented.");
250:            }
251:
252:            public boolean execute(String sql, int autoGeneratedKeys)
253:                    throws SQLException {
254:                throw new SQLException("Not implemented.");
255:            }
256:
257:            public boolean execute(String sql, int columnIndexes[])
258:                    throws SQLException {
259:                throw new SQLException("Not implemented.");
260:            }
261:
262:            public boolean execute(String sql, String columnNames[])
263:                    throws SQLException {
264:                throw new SQLException("Not implemented.");
265:            }
266:
267:            public int getResultSetHoldability() throws SQLException {
268:                checkOpen();
269:                throw new SQLException("Not implemented.");
270:            }
271:            /* JDBC_3_ANT_KEY_END */
272:
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.