Source Code Cross Referenced for DefaultLobHandler.java in  » J2EE » spring-framework-2.0.6 » org » springframework » jdbc » support » lob » 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 » J2EE » spring framework 2.0.6 » org.springframework.jdbc.support.lob 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 the original author or authors.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.jdbc.support.lob;
018:
019:        import java.io.InputStream;
020:        import java.io.Reader;
021:        import java.sql.PreparedStatement;
022:        import java.sql.ResultSet;
023:        import java.sql.SQLException;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:
028:        /**
029:         * Default implementation of the LobHandler interface. Invokes the
030:         * direct accessor methods that <code>java.sql.ResultSet</code> and
031:         * <code>java.sql.PreparedStatement</code> offer.
032:         *
033:         * <p>This LobHandler should work for any JDBC driver that is JDBC compliant
034:         * in terms of the spec's suggestions regarding simple BLOB and CLOB handling.
035:         * This does not apply to Oracle 9i, and only to a limited degree to Oracle 10g!
036:         * As a consequence, use OracleLobHandler for accessing Oracle BLOBs/CLOBs.
037:         *
038:         * @author Juergen Hoeller
039:         * @since 04.12.2003
040:         * @see OracleLobHandler
041:         * @see java.sql.ResultSet#getBytes
042:         * @see java.sql.ResultSet#getBinaryStream
043:         * @see java.sql.ResultSet#getString
044:         * @see java.sql.ResultSet#getAsciiStream
045:         * @see java.sql.ResultSet#getCharacterStream
046:         * @see java.sql.PreparedStatement#setBytes
047:         * @see java.sql.PreparedStatement#setBinaryStream
048:         * @see java.sql.PreparedStatement#setString
049:         * @see java.sql.PreparedStatement#setAsciiStream
050:         * @see java.sql.PreparedStatement#setCharacterStream
051:         */
052:        public class DefaultLobHandler extends AbstractLobHandler {
053:
054:            protected final Log logger = LogFactory.getLog(getClass());
055:
056:            public byte[] getBlobAsBytes(ResultSet rs, int columnIndex)
057:                    throws SQLException {
058:                logger.debug("Returning BLOB as bytes");
059:                return rs.getBytes(columnIndex);
060:            }
061:
062:            public InputStream getBlobAsBinaryStream(ResultSet rs,
063:                    int columnIndex) throws SQLException {
064:                logger.debug("Returning BLOB as binary stream");
065:                return rs.getBinaryStream(columnIndex);
066:            }
067:
068:            public String getClobAsString(ResultSet rs, int columnIndex)
069:                    throws SQLException {
070:                logger.debug("Returning CLOB as string");
071:                return rs.getString(columnIndex);
072:            }
073:
074:            public InputStream getClobAsAsciiStream(ResultSet rs,
075:                    int columnIndex) throws SQLException {
076:                logger.debug("Returning CLOB as ASCII stream");
077:                return rs.getAsciiStream(columnIndex);
078:            }
079:
080:            public Reader getClobAsCharacterStream(ResultSet rs, int columnIndex)
081:                    throws SQLException {
082:                logger.debug("Returning CLOB as character stream");
083:                return rs.getCharacterStream(columnIndex);
084:            }
085:
086:            public LobCreator getLobCreator() {
087:                logger.debug("Creating new DefaultLobCreator");
088:                return new DefaultLobCreator();
089:            }
090:
091:            protected class DefaultLobCreator implements  LobCreator {
092:
093:                public void setBlobAsBytes(PreparedStatement ps,
094:                        int paramIndex, byte[] content) throws SQLException {
095:
096:                    ps.setBytes(paramIndex, content);
097:                    if (logger.isDebugEnabled()) {
098:                        logger
099:                                .debug(content != null ? "Set bytes for BLOB with length "
100:                                        + content.length
101:                                        : "Set BLOB to null");
102:                    }
103:                }
104:
105:                public void setBlobAsBinaryStream(PreparedStatement ps,
106:                        int paramIndex, InputStream binaryStream,
107:                        int contentLength) throws SQLException {
108:
109:                    ps.setBinaryStream(paramIndex, binaryStream, contentLength);
110:                    if (logger.isDebugEnabled()) {
111:                        logger
112:                                .debug(binaryStream != null ? "Set binary stream for BLOB with length "
113:                                        + contentLength
114:                                        : "Set BLOB to null");
115:                    }
116:                }
117:
118:                public void setClobAsString(PreparedStatement ps,
119:                        int paramIndex, String content) throws SQLException {
120:
121:                    ps.setString(paramIndex, content);
122:                    if (logger.isDebugEnabled()) {
123:                        logger
124:                                .debug(content != null ? "Set string for CLOB with length "
125:                                        + content.length()
126:                                        : "Set CLOB to null");
127:                    }
128:                }
129:
130:                public void setClobAsAsciiStream(PreparedStatement ps,
131:                        int paramIndex, InputStream asciiStream,
132:                        int contentLength) throws SQLException {
133:
134:                    ps.setAsciiStream(paramIndex, asciiStream, contentLength);
135:                    if (logger.isDebugEnabled()) {
136:                        logger
137:                                .debug(asciiStream != null ? "Set ASCII stream for CLOB with length "
138:                                        + contentLength
139:                                        : "Set CLOB to null");
140:                    }
141:                }
142:
143:                public void setClobAsCharacterStream(PreparedStatement ps,
144:                        int paramIndex, Reader characterStream,
145:                        int contentLength) throws SQLException {
146:
147:                    ps.setCharacterStream(paramIndex, characterStream,
148:                            contentLength);
149:                    if (logger.isDebugEnabled()) {
150:                        logger
151:                                .debug(characterStream != null ? "Set character stream for CLOB with length "
152:                                        + contentLength
153:                                        : "Set CLOB to null");
154:                    }
155:                }
156:
157:                public void close() {
158:                    logger.debug("Closing DefaultLobCreator");
159:                    // nothing to do here
160:                }
161:            }
162:
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.