Source Code Cross Referenced for JdbcColumnMetaData.java in  » EJB-Server-resin-3.1.5 » quercus » com » caucho » quercus » lib » db » 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 » EJB Server resin 3.1.5 » quercus » com.caucho.quercus.lib.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.quercus.lib.db;
031:
032:        import java.sql.DatabaseMetaData;
033:        import java.sql.ResultSet;
034:        import java.sql.SQLException;
035:        import java.sql.Types;
036:
037:        /**
038:         * Represents a JDBC column metadata
039:         */
040:        public class JdbcColumnMetaData {
041:            private final JdbcTableMetaData _table;
042:
043:            private final String _name;
044:
045:            private final int _jdbcType;
046:
047:            private final int _length;
048:
049:            private final boolean _isNotNull;
050:            private final boolean _isUnsigned;
051:            private final boolean _isZeroFill;
052:
053:            private boolean _isPrimaryKey;
054:            private boolean _isIndex;
055:            private boolean _isUnique;
056:
057:            /**
058:             * @param rs the ResultSet from a DatabaseMetaData.getColumns call
059:             */
060:            public JdbcColumnMetaData(JdbcTableMetaData table, ResultSet rs)
061:                    throws SQLException {
062:                _table = table;
063:
064:                // COLUMN_NAME
065:                _name = rs.getString(4);
066:                // DATA_TYPE
067:                _jdbcType = rs.getInt(5);
068:                // COLUMN_SIZE
069:                _length = rs.getInt(7);
070:
071:                // NULLABLE
072:                _isNotNull = rs.getInt(11) == DatabaseMetaData.columnNoNulls;
073:
074:                // TYPE_NAME
075:                String type = rs.getString(6).toLowerCase();
076:
077:                _isUnsigned = type.indexOf("unsigned") >= 0;
078:                _isZeroFill = type.indexOf("zerofill") >= 0;
079:            }
080:
081:            /**
082:             * Returns the column's name.
083:             */
084:            public String getName() {
085:                return _name;
086:            }
087:
088:            /**
089:             * Returns the column's table
090:             */
091:            public JdbcTableMetaData getTable() {
092:                return _table;
093:            }
094:
095:            /**
096:             * Returns the column length.
097:             */
098:            public int getLength() {
099:                return _length;
100:            }
101:
102:            /**
103:             * Returns true if the column is nullable.
104:             */
105:            public boolean isNotNull() {
106:                return _isNotNull;
107:            }
108:
109:            /**
110:             * Returns true for a primary key.
111:             */
112:            public boolean isPrimaryKey() {
113:                return _isPrimaryKey;
114:            }
115:
116:            /**
117:             * Set true for a primary key.
118:             */
119:            void setPrimaryKey(boolean isPrimaryKey) {
120:                _isPrimaryKey = isPrimaryKey;
121:            }
122:
123:            /**
124:             * Returns true for an index
125:             */
126:            public boolean isIndex() {
127:                return _isIndex;
128:            }
129:
130:            /**
131:             * Set true for an index
132:             */
133:            void setIndex(boolean isIndex) {
134:                _isIndex = isIndex;
135:            }
136:
137:            /**
138:             * Returns true for a unique column
139:             */
140:            public boolean isUnique() {
141:                return _isUnique;
142:            }
143:
144:            /**
145:             * Set true for a unique column
146:             */
147:            void setUnique(boolean isUnique) {
148:                _isUnique = isUnique;
149:            }
150:
151:            /**
152:             * Returns the JDBC type.
153:             */
154:            public int getJdbcType() {
155:                return _jdbcType;
156:            }
157:
158:            /**
159:             * Returns true for numeric data types.
160:             */
161:            public static boolean isNumeric(int jdbcType) {
162:                switch (jdbcType) {
163:                case Types.BIT:
164:                case Types.TINYINT:
165:                case Types.SMALLINT:
166:                case Types.INTEGER:
167:                case Types.BIGINT:
168:                case Types.DOUBLE:
169:                case Types.FLOAT:
170:                case Types.REAL:
171:                    return true;
172:                default:
173:                    return false;
174:                }
175:            }
176:
177:            /**
178:             * Returns true for numeric data types.
179:             */
180:            public boolean isNumeric() {
181:                return isNumeric(_jdbcType);
182:            }
183:
184:            /**
185:             * Returns true for float data types.
186:             */
187:            public boolean isFloat() {
188:                switch (_jdbcType) {
189:                case Types.DOUBLE:
190:                case Types.FLOAT:
191:                case Types.REAL:
192:                    return true;
193:                default:
194:                    return false;
195:                }
196:            }
197:
198:            /**
199:             * Returns true for unsigned.
200:             */
201:            public boolean isUnsigned() {
202:                return _isUnsigned;
203:            }
204:
205:            /**
206:             * Returns true for zerofill
207:             */
208:            public boolean isZeroFill() {
209:                return _isZeroFill;
210:            }
211:
212:            /**
213:             * Returns true for blob data types.
214:             */
215:            public static boolean isBlob(int jdbcType) {
216:                switch (jdbcType) {
217:                // php/142s
218:                // php/142v
219:                case Types.LONGVARBINARY:
220:                case Types.LONGVARCHAR:
221:                case Types.BLOB:
222:                case Types.CLOB:
223:                    return true;
224:                default:
225:                    return false;
226:                }
227:            }
228:
229:            /**
230:             * Returns true for blob data types.
231:             */
232:            public boolean isBlob() {
233:                return isBlob(_jdbcType);
234:            }
235:
236:            public String toString() {
237:                return "JdbcColumnMetaData[" + getName() + "]";
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.