Source Code Cross Referenced for AbstractConnectionImpl.java in  » Rule-Engine » Mandarax » org » mandarax » 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 » Rule Engine » Mandarax » org.mandarax.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package org.mandarax.jdbc;
020:
021:        import java.sql.*;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:        import org.mandarax.jdbc.server.DatabaseMetaDataImpl;
025:        import org.mandarax.util.logging.LogCategories;
026:
027:        /**
028:         * Base class for connection implementations.
029:         * @author <A HREF="mailto:mandarax@jbdietrich.com">Jens Dietrich</A>
030:         * @version 3.3.2 <29 December 2004>
031:         * @since 3.0
032:         */
033:
034:        public abstract class AbstractConnectionImpl implements 
035:                java.sql.Connection, LogCategories {
036:
037:            protected String url = null;
038:            private Map typeMap = new HashMap();
039:
040:            /*
041:             * Constructor.
042:             * @param url the database url
043:             */
044:            protected AbstractConnectionImpl(String url) {
045:                super ();
046:                this .url = url;
047:            }
048:
049:            /**
050:             * Creates a CallableStatement object for calling database stored procedures.
051:             */
052:            public CallableStatement prepareCall(String sql)
053:                    throws SQLException {
054:                this .notSupportedThrowException("prepareCall");
055:                return null;
056:            }
057:
058:            /*
059:             * Converts the given SQL statement into the system's native SQL grammar.
060:             * @see java.sql.Connection#nativeSQL(java.lang.String)
061:             */
062:            public String nativeSQL(String sql) throws SQLException {
063:                return sql;
064:            }
065:
066:            /**
067:             * This driver does not support transactions/ DML write operations!
068:             * A NotSupportedException is thrown.
069:             */
070:            public void setAutoCommit(boolean autoCommit) throws SQLException {
071:                notSupported("setAutoCommit");
072:            }
073:
074:            /*
075:             * This driver does not support transactions/ DML write operations!
076:             * A NotSupportedException is thrown.
077:             */
078:            public boolean getAutoCommit() throws SQLException {
079:                notSupported("getAutoCommit");
080:                return false;
081:            }
082:
083:            /**
084:             * This driver does not support transactions/ DML write operations!
085:             * A NotSupportedException is thrown.
086:             */
087:            public void commit() throws SQLException {
088:                notSupported("commit");
089:            }
090:
091:            /**
092:             * This driver does not support transactions/ DML write operations!
093:             * A NotSupportedException is thrown.
094:             */
095:            public void rollback() throws SQLException {
096:                notSupported("rollback");
097:            }
098:
099:            /**
100:             * Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.
101:             */
102:            public void close() throws SQLException {
103:                // TODO this should close open result sets
104:            }
105:
106:            /**
107:             * Retrieves whether this Connection object has been closed.
108:             * @return a boolean
109:             */
110:            public boolean isClosed() throws SQLException {
111:                return false;
112:            }
113:
114:            /**
115:             * Puts this connection in read-only mode as a hint to the driver to enable database optimizations.
116:             * @param a boolean
117:             */
118:            public void setReadOnly(boolean readOnly) throws SQLException {
119:                this .notSupported("setReadOnly");
120:            }
121:
122:            /**
123:             * Always returns true - this API does not support DML write operations.
124:             * @return a boolean
125:             */
126:            public boolean isReadOnly() throws SQLException {
127:                this .notSupported("isReadOnly");
128:                return true;
129:            }
130:
131:            /**
132:             * Sets the given catalog name in order to select a subspace of this Connection object's database in which to work.
133:             * @param catalog a catalog (name)
134:             */
135:            public void setCatalog(String catalog) throws SQLException {
136:                if (!DatabaseMetaDataImpl.DEFAULT_CATALOG.equals(catalog))
137:                    throw new SQLException("Unknown catalog " + catalog);
138:            }
139:
140:            /**
141:             * Retrieves this Connection object's current catalog name.
142:             * @see java.sql.Connection#getCatalog()
143:             */
144:            public String getCatalog() throws SQLException {
145:                return DatabaseMetaDataImpl.DEFAULT_CATALOG;
146:            }
147:
148:            /**
149:             * Attempts to change the transaction isolation level for this Connection object to the one given.
150:             * @param level the new transaction isolation level
151:             */
152:            public void setTransactionIsolation(int level) throws SQLException {
153:                this .notSupported("setTransactionIsolation");
154:            }
155:
156:            /**
157:             * Retrieves this Connection object's current transaction isolation level.
158:             * @return always Connection.TRANSACTION_NONE
159:             */
160:            public int getTransactionIsolation() throws SQLException {
161:                return Connection.TRANSACTION_NONE;
162:            }
163:
164:            /**
165:             * Retrieves the first warning reported by calls on this Connection object.
166:             * @return a warning
167:             */
168:            public SQLWarning getWarnings() throws SQLException {
169:                this .notSupported("getWarnings");
170:                return null;
171:            }
172:
173:            /**
174:             * Clears all warnings reported for this Connection object.
175:             */
176:            public void clearWarnings() throws SQLException {
177:                // nothing to do
178:            }
179:
180:            /**
181:             * Creates a Statement object that will generate ResultSet objects with the given type and concurrency.
182:             * Parameters will be ignored.
183:             * @param resultSetType the result set type
184:             * @param resultSetConcurrency the result set concurrency
185:             */
186:            public Statement createStatement(int resultSetType,
187:                    int resultSetConcurrency) throws SQLException {
188:                if (LOG_JDBC.isDebugEnabled())
189:                    LOG_JDBC
190:                            .debug("Ignore parameters resultSetType and resultSetConcurrency in createStatement");
191:                return createStatement();
192:            }
193:
194:            /**
195:             * Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.
196:             * @param sql the query
197:             * @param resultSetType the rsult set type
198:             * @param resultSetConcurrency the result set concurrency
199:             */
200:            public PreparedStatement prepareStatement(String sql,
201:                    int resultSetType, int resultSetConcurrency)
202:                    throws SQLException {
203:                if (LOG_JDBC.isDebugEnabled())
204:                    LOG_JDBC
205:                            .debug("Ignore parameters resultSetType and resultSetConcurrency in prepareStatement");
206:                return prepareStatement(sql);
207:            }
208:
209:            /**
210:             * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
211:             * @param resultSetType the rsult set type
212:             * @param resultSetConcurrency the result set concurrency
213:             */
214:            public CallableStatement prepareCall(String sql, int resultSetType,
215:                    int resultSetConcurrency) throws SQLException {
216:                this .notSupported("prepareCall");
217:                return null;
218:            }
219:
220:            /**
221:             * Retrieves the Map object associated with this Connection object.
222:             * @return a map
223:             */
224:            public Map getTypeMap() throws SQLException {
225:                return typeMap;
226:            }
227:
228:            // Java 1.5
229:            /**
230:             * Installs the given TypeMap object as the type map for this Connection object.
231:             * @param map a type map
232:             */
233:            public void setTypeMap(Map/*<String,Class<?>>*/map)
234:                    throws SQLException {
235:                typeMap = map;
236:            }
237:
238:            /**
239:             * Changes the holdability of ResultSet objects created using this Connection object to the given holdability.
240:             * @param holdability the result set holdability
241:             */
242:            public void setHoldability(int holdability) throws SQLException {
243:                notSupported("setHoldability");
244:            }
245:
246:            /**
247:             * Retrieves the current holdability of ResultSet objects created using this Connection object.
248:             * @return the result set holdability
249:             */
250:            public int getHoldability() throws SQLException {
251:                return java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT;
252:            }
253:
254:            /**
255:             * This driver does not support transactions/ DML write operations!
256:             * A NotSupportedException is thrown.
257:             */
258:            public Savepoint setSavepoint() throws SQLException {
259:                notSupported("setSavepoint");
260:                return null;
261:            }
262:
263:            /**
264:             * This driver does not support transactions/ DML write operations!
265:             * A NotSupportedException is thrown.
266:             */
267:            public Savepoint setSavepoint(String name) throws SQLException {
268:                notSupported("setSavepoint(String)");
269:                return null;
270:            }
271:
272:            /**
273:             * This driver does not support transactions/ DML write operations!
274:             * A NotSupportedException is thrown.
275:             */
276:            public void rollback(Savepoint savepoint) throws SQLException {
277:                notSupported("rollback(Savepoint)");
278:            }
279:
280:            /**
281:             * This driver does not support transactions/ DML write operations!
282:             * A NotSupportedException is thrown.
283:             */
284:            public void releaseSavepoint(Savepoint savepoint)
285:                    throws SQLException {
286:                notSupported("releaseSavepoint(Savepoint)");
287:            }
288:
289:            /**
290:             * Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
291:             * @param resultSetType the rsult set type
292:             * @param resultSetConcurrency the result set concurrency
293:             * @param resultSetHoldability the result set holdability
294:             */
295:            public Statement createStatement(int resultSetType,
296:                    int resultSetConcurrency, int resultSetHoldability)
297:                    throws SQLException {
298:                if (LOG_JDBC.isDebugEnabled())
299:                    LOG_JDBC
300:                            .debug("Ignore parameters resultSetType, resultSetConcurrency and resultSetHoldability in createStatement");
301:                return createStatement();
302:            }
303:
304:            /**
305:             * Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.
306:             * @param sql the sql statement
307:             * @param resultSetType the rsult set type
308:             * @param resultSetConcurrency the result set concurrency
309:             * @param resultSetHoldability the result set holdability
310:             */
311:            public PreparedStatement prepareStatement(String sql,
312:                    int resultSetType, int resultSetConcurrency,
313:                    int resultSetHoldability) throws SQLException {
314:                if (LOG_JDBC.isDebugEnabled())
315:                    LOG_JDBC
316:                            .debug("Ignore parameters resultSetType, resultSetConcurrency and resultSetHoldability in prepareStatement");
317:                return prepareStatement(sql);
318:            }
319:
320:            /**
321:             * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
322:             */
323:            public CallableStatement prepareCall(String sql, int resultSetType,
324:                    int resultSetConcurrency, int resultSetHoldability)
325:                    throws SQLException {
326:                this 
327:                        .notSupportedThrowException("prepareCall(String,int,int,int)");
328:                return null;
329:            }
330:
331:            /**
332:             * Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.
333:             * @param sql the sql string
334:             * @param autoGeneratedKeys a flag indicating whether auto-generated keys should be returned
335:             */
336:            public PreparedStatement prepareStatement(String sql,
337:                    int autoGeneratedKeys) throws SQLException {
338:                if (LOG_JDBC.isDebugEnabled())
339:                    LOG_JDBC
340:                            .debug("Ignore parameter autoGenerateKeys in prepareStatement");
341:                return prepareStatement(sql);
342:            }
343:
344:            /**
345:             * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
346:             * @param sql the sql string
347:             * @param columnIndexes an array of column indexes indicating the columns that should be returned from the inserted row or rows
348:             */
349:            public PreparedStatement prepareStatement(String sql,
350:                    int[] columnIndexes) throws SQLException {
351:                if (LOG_JDBC.isDebugEnabled())
352:                    LOG_JDBC
353:                            .debug("Ignore parameter columnIndexes in prepareStatement");
354:                return prepareStatement(sql);
355:            }
356:
357:            /**
358:             * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
359:             * @param sql the sql string
360:             * @param columnNames an array of column names indicating the columns that should be returned from the inserted row or rows
361:             */
362:            public PreparedStatement prepareStatement(String sql,
363:                    String[] columnNames) throws SQLException {
364:                if (LOG_JDBC.isDebugEnabled())
365:                    LOG_JDBC
366:                            .debug("Ignore parameter columnNames in prepareStatement");
367:                return prepareStatement(sql);
368:            }
369:
370:            /**
371:             * Log a call of an unsupported method.
372:             * @param methodName the name of the method
373:             */
374:            private void notSupported(String methodName) {
375:                JDBCUtils.notSupported(methodName, this );
376:            }
377:
378:            /**
379:             * Log a call of an unsupported method.
380:             * This call throws an exception.
381:             * @param methodName the name of the method
382:             */
383:            private void notSupportedThrowException(String methodName)
384:                    throws SQLException {
385:                JDBCUtils.notSupportedThrowException(methodName, this);
386:            }
387:
388:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.