Source Code Cross Referenced for BrokeredConnection40.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » iapi » jdbc » 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 DBMS » db derby 10.2 » org.apache.derby.iapi.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         
003:           Derby - Class org.apache.derby.iapi.jdbc.BrokeredConnection40
004:         
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           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, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:         
020:         */
021:
022:        package org.apache.derby.iapi.jdbc;
023:
024:        import java.sql.Array;
025:        import java.sql.Blob;
026:        import java.sql.Clob;
027:        import java.sql.Connection;
028:        import java.sql.SQLClientInfoException;
029:        import java.sql.NClob;
030:        import java.sql.SQLException;
031:        import java.sql.SQLXML;
032:        import java.sql.Struct;
033:        import java.util.Properties;
034:        import org.apache.derby.impl.jdbc.Util; //import org.apache.derby.impl.jdbc.EmbedConnection40;
035:        import org.apache.derby.iapi.reference.SQLState;
036:
037:        public class BrokeredConnection40 extends BrokeredConnection30 {
038:
039:            /** Creates a new instance of BrokeredConnection40 */
040:            public BrokeredConnection40(BrokeredConnectionControl control) {
041:                super (control);
042:            }
043:
044:            public Array createArrayOf(String typeName, Object[] elements)
045:                    throws SQLException {
046:                try {
047:                    return getRealConnection()
048:                            .createArrayOf(typeName, elements);
049:                } catch (SQLException sqle) {
050:                    notifyException(sqle);
051:                    throw sqle;
052:                }
053:            }
054:
055:            /**
056:             *
057:             * Constructs an object that implements the <code>Blob</code> interface. The object
058:             * returned initially contains no data.  The <code>setBinaryStream</code> and
059:             * <code>setBytes</code> methods of the <code>Blob</code> interface may be used to add data to
060:             * the <code>Blob</code>.
061:             *
062:             * @return  An object that implements the <code>Blob</code> interface
063:             * @throws SQLException if an object that implements the
064:             * <code>Blob</code> interface can not be constructed, this method is 
065:             * called on a closed connection or a database access error occurs.
066:             *
067:             */
068:            public Blob createBlob() throws SQLException {
069:                if (isClosed()) {
070:                    throw Util.noCurrentConnection();
071:                }
072:                // Forward the createBlob call to the physical connection
073:                try {
074:                    return getRealConnection().createBlob();
075:                } catch (SQLException sqle) {
076:                    notifyException(sqle);
077:                    throw sqle;
078:                }
079:            }
080:
081:            /**
082:             *
083:             * Constructs an object that implements the <code>Clob</code> interface. The object
084:             * returned initially contains no data.  The <code>setAsciiStream</code>,
085:             * <code>setCharacterStream</code> and <code>setString</code> methods of 
086:             * the <code>Clob</code> interface may be used to add data to the <code>Clob</code>.
087:             *
088:             * @return An object that implements the <code>Clob</code> interface
089:             * @throws SQLException if an object that implements the
090:             * <code>Clob</code> interface can not be constructed, this method is 
091:             * called on a closed connection or a database access error occurs.
092:             *
093:             */
094:            public Clob createClob() throws SQLException {
095:                if (isClosed()) {
096:                    throw Util.noCurrentConnection();
097:                }
098:                // Forward the createClob call to the physical connection
099:                try {
100:                    return getRealConnection().createClob();
101:                } catch (SQLException sqle) {
102:                    notifyException(sqle);
103:                    throw sqle;
104:                }
105:            }
106:
107:            public NClob createNClob() throws SQLException {
108:                try {
109:                    return getRealConnection().createNClob();
110:                } catch (SQLException sqle) {
111:                    notifyException(sqle);
112:                    throw sqle;
113:                }
114:            }
115:
116:            public SQLXML createSQLXML() throws SQLException {
117:                try {
118:                    return getRealConnection().createSQLXML();
119:                } catch (SQLException sqle) {
120:                    notifyException(sqle);
121:                    throw sqle;
122:                }
123:            }
124:
125:            public Struct createStruct(String typeName, Object[] attributes)
126:                    throws SQLException {
127:                try {
128:                    return getRealConnection().createStruct(typeName,
129:                            attributes);
130:                } catch (SQLException sqle) {
131:                    notifyException(sqle);
132:                    throw sqle;
133:                }
134:            }
135:
136:            /**
137:             * Checks if the connection has not been closed and is still valid. 
138:             * The validity is checked by running a simple query against the 
139:             * database.
140:             *
141:             * @param timeout The time in seconds to wait for the database
142:             * operation used to validate the connection to complete. If the 
143:             * timeout period expires before the operation completes, this 
144:             * method returns false. A value of 0 indicates a timeout is not 
145:             * applied to the database operation.
146:             * @return true if the connection is valid, false otherwise
147:             * @throws SQLException if the call on the physical connection throws an
148:             * exception.
149:             */
150:            public final boolean isValid(int timeout) throws SQLException {
151:                // Check first if the Brokered connection is closed
152:                if (isClosed()) {
153:                    return false;
154:                }
155:
156:                // Forward the isValid call to the physical connection
157:                try {
158:                    return getRealConnection().isValid(timeout);
159:                } catch (SQLException sqle) {
160:                    notifyException(sqle);
161:                    throw sqle;
162:                }
163:            }
164:
165:            /**
166:             * <code>setClientInfo</code> forwards to the real connection.
167:             *
168:             * @param name the property key <code>String</code>
169:             * @param value the property value <code>String</code>
170:             * @exception SQLClientInfoException if the property is not
171:             * supported or the real connection could not be obtained.
172:             */
173:            public void setClientInfo(String name, String value)
174:                    throws SQLClientInfoException {
175:                try {
176:                    getRealConnection().setClientInfo(name, value);
177:                } catch (SQLClientInfoException se) {
178:                    notifyException(se);
179:                    throw se;
180:                } catch (SQLException se) {
181:                    throw new SQLClientInfoException(se.getMessage(), se
182:                            .getSQLState(), (new FailedProperties40(
183:                            FailedProperties40.makeProperties(name, value)))
184:                            .getProperties());
185:                }
186:            }
187:
188:            /**
189:             * <code>setClientInfo</code> forwards to the real connection.  If
190:             * the call to <code>getRealConnection</code> fails the resulting
191:             * <code>SQLException</code> is wrapped in a
192:             * <code>SQLClientInfoException</code> to satisfy the specified
193:             * signature.
194:             * @param properties a <code>Properties</code> object with the
195:             * properties to set.
196:             * @exception SQLClientInfoException if the properties are not
197:             * supported or the real connection could not be obtained.
198:             */
199:            public void setClientInfo(Properties properties)
200:                    throws SQLClientInfoException {
201:                try {
202:                    getRealConnection().setClientInfo(properties);
203:                } catch (SQLClientInfoException cie) {
204:                    notifyException(cie);
205:                    throw cie;
206:                } catch (SQLException se) {
207:                    throw new SQLClientInfoException(se.getMessage(), se
208:                            .getSQLState(),
209:                            (new FailedProperties40(properties))
210:                                    .getProperties());
211:                }
212:            }
213:
214:            /**
215:             * <code>getClientInfo</code> forwards to the real connection.
216:             *
217:             * @param name a <code>String</code> that is the property key to get.
218:             * @return a <code>String</code> that is returned from the real connection.
219:             * @exception SQLException if a database access error occurs.
220:             */
221:            public String getClientInfo(String name) throws SQLException {
222:                try {
223:                    return getRealConnection().getClientInfo(name);
224:                } catch (SQLException se) {
225:                    notifyException(se);
226:                    throw se;
227:                }
228:            }
229:
230:            /**
231:             * <code>getClientInfo</code> forwards to the real connection.
232:             *
233:             * @return a <code>Properties</code> object
234:             * from the real connection.
235:             * @exception SQLException if a database access error occurs.
236:             */
237:            public Properties getClientInfo() throws SQLException {
238:                try {
239:                    return getRealConnection().getClientInfo();
240:                } catch (SQLException se) {
241:                    notifyException(se);
242:                    throw se;
243:                }
244:            }
245:
246:            /**
247:             * returns an instance of JDBC4.0 speccific class BrokeredStatement40
248:             * @param  statementControl BrokeredStatementControl
249:             * @return an instance of BrokeredStatement40 
250:             * throws java.sql.SQLException
251:             */
252:            public final BrokeredStatement newBrokeredStatement(
253:                    BrokeredStatementControl statementControl)
254:                    throws SQLException {
255:                try {
256:                    return new BrokeredStatement40(statementControl,
257:                            getJDBCLevel());
258:                } catch (SQLException sqle) {
259:                    notifyException(sqle);
260:                    throw sqle;
261:                }
262:            }
263:
264:            public final BrokeredPreparedStatement newBrokeredStatement(
265:                    BrokeredStatementControl statementControl, String sql,
266:                    Object generatedKeys) throws SQLException {
267:                try {
268:                    return new BrokeredPreparedStatement40(statementControl,
269:                            getJDBCLevel(), sql, generatedKeys);
270:                } catch (SQLException sqle) {
271:                    notifyException(sqle);
272:                    throw sqle;
273:                }
274:            }
275:
276:            public final BrokeredCallableStatement newBrokeredStatement(
277:                    BrokeredStatementControl statementControl, String sql)
278:                    throws SQLException {
279:                try {
280:                    return new BrokeredCallableStatement40(statementControl,
281:                            getJDBCLevel(), sql);
282:                } catch (SQLException sqle) {
283:                    notifyException(sqle);
284:                    throw sqle;
285:                }
286:            }
287:
288:            /**
289:             * Returns the type map for this connection.
290:             *
291:             * @return type map for this connection
292:             * @exception SQLException if a database access error occurs
293:             */
294:            public final java.util.Map<String, Class<?>> getTypeMap()
295:                    throws SQLException {
296:                try {
297:                    return getRealConnection().getTypeMap();
298:                } catch (SQLException se) {
299:                    notifyException(se);
300:                    throw se;
301:                }
302:            }
303:
304:            final int getJDBCLevel() {
305:                return 4;
306:            }
307:
308:            /**
309:             * Returns false unless <code>interfaces</code> is implemented 
310:             * 
311:             * @param  interfaces             a Class defining an interface.
312:             * @return true                   if this implements the interface or 
313:             *                                directly or indirectly wraps an object 
314:             *                                that does.
315:             * @throws java.sql.SQLException  if an error occurs while determining 
316:             *                                whether this is a wrapper for an object 
317:             *                                with the given interface.
318:             */
319:            public final boolean isWrapperFor(Class<?> interfaces)
320:                    throws SQLException {
321:                checkIfClosed();
322:                return interfaces.isInstance(this );
323:            }
324:
325:            /**
326:             * Returns <code>this</code> if this class implements the interface
327:             *
328:             * @param  interfaces a Class defining an interface
329:             * @return an object that implements the interface
330:             * @throws java.sql.SQLExption if no object if found that implements the 
331:             * interface
332:             */
333:            public final <T> T unwrap(java.lang.Class<T> interfaces)
334:                    throws SQLException {
335:                checkIfClosed();
336:                //Derby does not implement non-standard methods on 
337:                //JDBC objects
338:                try {
339:                    return interfaces.cast(this );
340:                } catch (ClassCastException cce) {
341:                    throw Util.generateCsSQLException(
342:                            SQLState.UNABLE_TO_UNWRAP, interfaces);
343:                }
344:            }
345:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.