Source Code Cross Referenced for OracleDataHandler.java in  » Scripting » jython » com » ziclix » python » sql » handler » 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 » Scripting » jython » com.ziclix.python.sql.handler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jython Database Specification API 2.0
003:         *
004:         * $Id: OracleDataHandler.java 2414 2005-02-23 04:26:23Z bzimmer $
005:         *
006:         * Copyright (c) 2001 brian zimmer <bzimmer@ziclix.com>
007:         *
008:         */
009:        package com.ziclix.python.sql.handler;
010:
011:        import com.ziclix.python.sql.DataHandler;
012:        import com.ziclix.python.sql.FilterDataHandler;
013:        import com.ziclix.python.sql.zxJDBC;
014:        import oracle.jdbc.driver.OracleResultSet;
015:        import oracle.jdbc.driver.OracleTypes;
016:        import oracle.sql.BLOB;
017:        import oracle.sql.ROWID;
018:        import org.python.core.Py;
019:        import org.python.core.PyObject;
020:
021:        import java.io.BufferedInputStream;
022:        import java.io.InputStream;
023:        import java.sql.CallableStatement;
024:        import java.sql.PreparedStatement;
025:        import java.sql.ResultSet;
026:        import java.sql.SQLException;
027:        import java.sql.Types;
028:
029:        /**
030:         * Oracle specific data handling.
031:         *
032:         * @author brian zimmer
033:         * @author last revised by $Author: bzimmer $
034:         * @version $Revision: 2414 $
035:         */
036:        public class OracleDataHandler extends FilterDataHandler {
037:
038:            /**
039:             * Default constructor for DataHandler filtering.
040:             */
041:            public OracleDataHandler(DataHandler datahandler) {
042:                super (datahandler);
043:            }
044:
045:            /**
046:             * Method getMetaDataName
047:             *
048:             * @param name
049:             * @return String
050:             */
051:            public String getMetaDataName(PyObject name) {
052:
053:                String metaName = super .getMetaDataName(name);
054:
055:                return (metaName == null) ? null : metaName.toUpperCase();
056:            }
057:
058:            /**
059:             * Provide functionality for Oracle specific types, such as ROWID.
060:             */
061:            public void setJDBCObject(PreparedStatement stmt, int index,
062:                    PyObject object, int type) throws SQLException {
063:
064:                if (DataHandler.checkNull(stmt, index, object, type)) {
065:                    return;
066:                }
067:
068:                switch (type) {
069:
070:                case OracleTypes.ROWID:
071:                    stmt.setString(index, (String) object
072:                            .__tojava__(String.class));
073:                    break;
074:
075:                case Types.DECIMAL:
076:
077:                    // Oracle is annoying
078:                    Object input = object.__tojava__(Double.class);
079:
080:                    if (input != Py.NoConversion) {
081:                        stmt.setDouble(index, ((Double) input).doubleValue());
082:
083:                        break;
084:                    }
085:
086:                    super .setJDBCObject(stmt, index, object, type);
087:                    break;
088:
089:                case Types.NUMERIC:
090:                    super .setJDBCObject(stmt, index, object, Types.DOUBLE);
091:                    break;
092:
093:                case Types.BLOB:
094:                case Types.CLOB:
095:                    Integer[] vals = { new Integer(index), new Integer(type) };
096:                    String msg = zxJDBC.getString("errorSettingIndex", vals);
097:
098:                    throw new SQLException(msg);
099:                default:
100:                    super .setJDBCObject(stmt, index, object, type);
101:                }
102:            }
103:
104:            /**
105:             * Provide functionality for Oracle specific types, such as ROWID.
106:             */
107:            public PyObject getPyObject(ResultSet set, int col, int type)
108:                    throws SQLException {
109:
110:                PyObject obj = Py.None;
111:
112:                switch (type) {
113:
114:                case Types.BLOB:
115:                    BLOB blob = ((OracleResultSet) set).getBLOB(col);
116:
117:                    if (blob == null) {
118:                        return Py.None;
119:                    }
120:
121:                    InputStream stream = new BufferedInputStream(blob
122:                            .getBinaryStream());
123:
124:                    obj = Py.java2py(DataHandler.read(stream));
125:                    break;
126:
127:                case OracleTypes.ROWID:
128:                    ROWID rowid = ((OracleResultSet) set).getROWID(col);
129:
130:                    if (rowid != null) {
131:                        obj = Py.java2py(rowid.stringValue());
132:                    }
133:                    break;
134:
135:                default:
136:                    obj = super .getPyObject(set, col, type);
137:                }
138:
139:                return (set.wasNull() ? Py.None : obj);
140:            }
141:
142:            /**
143:             * Called when a stored procedure or function is executed and OUT parameters
144:             * need to be registered with the statement.
145:             *
146:             * @param statement
147:             * @param index the JDBC offset column number
148:             * @param colType the column as from DatabaseMetaData (eg, procedureColumnOut)
149:             * @param dataType the JDBC datatype from Types
150:             * @param dataTypeName the JDBC datatype name
151:             * @throws SQLException
152:             */
153:            public void registerOut(CallableStatement statement, int index,
154:                    int colType, int dataType, String dataTypeName)
155:                    throws SQLException {
156:
157:                if (dataType == Types.OTHER) {
158:                    if ("REF CURSOR".equals(dataTypeName)) {
159:                        statement.registerOutParameter(index,
160:                                OracleTypes.CURSOR);
161:
162:                        return;
163:                    } else if ("PL/SQL RECORD".equals(dataTypeName)) {
164:                        statement.registerOutParameter(index,
165:                                OracleTypes.CURSOR);
166:
167:                        return;
168:                    }
169:                }
170:
171:                super.registerOut(statement, index, colType, dataType,
172:                        dataTypeName);
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.