Source Code Cross Referenced for DBPostgres.java in  » Database-ORM » Torque » org » apache » torque » adapter » 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 ORM » Torque » org.apache.torque.adapter 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.torque.adapter;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with 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,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.sql.Connection;
023:        import java.sql.SQLException;
024:        import java.text.DateFormat;
025:        import java.text.SimpleDateFormat;
026:        import java.util.Date;
027:
028:        import org.apache.torque.util.Query;
029:
030:        /**
031:         * This is used to connect to PostgresQL databases.
032:         *
033:         * <a href="http://www.postgresql.org/">http://www.postgresql.org/</a>
034:         *
035:         * @author <a href="mailto:hakan42@gmx.de">Hakan Tandogan</a>
036:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
037:         * @version $Id: DBPostgres.java 522044 2007-03-24 16:00:57Z tfischer $
038:         */
039:        public class DBPostgres extends AbstractDBAdapter {
040:            /**
041:             * Serial version
042:             */
043:            private static final long serialVersionUID = 7643304924262475272L;
044:
045:            /** A specialized date format for PostgreSQL. */
046:            private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
047:
048:            /**
049:             * Empty constructor.
050:             */
051:            protected DBPostgres() {
052:            }
053:
054:            /**
055:             * This method is used to ignore case.
056:             *
057:             * @param in The string to transform to upper case.
058:             * @return The upper case string.
059:             */
060:            public String toUpperCase(String in) {
061:                String s = new StringBuffer("UPPER(").append(in).append(")")
062:                        .toString();
063:                return s;
064:            }
065:
066:            /**
067:             * This method is used to ignore case.
068:             *
069:             * @param in The string whose case to ignore.
070:             * @return The string in a case that can be ignored.
071:             */
072:            public String ignoreCase(String in) {
073:                String s = new StringBuffer("UPPER(").append(in).append(")")
074:                        .toString();
075:                return s;
076:            }
077:
078:            /**
079:             * @see org.apache.torque.adapter.DB#getIDMethodType()
080:             */
081:            public String getIDMethodType() {
082:                return SEQUENCE;
083:            }
084:
085:            /**
086:             * @param name The name of the field (should be of type
087:             *      <code>String</code>).
088:             * @return SQL to retreive the next database key.
089:             * @see org.apache.torque.adapter.DB#getIDMethodSQL(Object)
090:             */
091:            public String getIDMethodSQL(Object name) {
092:                return ("select nextval('" + name + "')");
093:            }
094:
095:            /**
096:             * Locks the specified table.
097:             *
098:             * @param con The JDBC connection to use.
099:             * @param table The name of the table to lock.
100:             * @exception SQLException No Statement could be created or executed.
101:             */
102:            public void lockTable(Connection con, String table)
103:                    throws SQLException {
104:            }
105:
106:            /**
107:             * Unlocks the specified table.
108:             *
109:             * @param con The JDBC connection to use.
110:             * @param table The name of the table to unlock.
111:             * @exception SQLException No Statement could be created or executed.
112:             */
113:            public void unlockTable(Connection con, String table)
114:                    throws SQLException {
115:            }
116:
117:            /**
118:             * This method is used to chek whether the database supports
119:             * limiting the size of the resultset.
120:             *
121:             * @return LIMIT_STYLE_POSTGRES.
122:             * @deprecated This should not be exposed to the outside
123:             */
124:            public int getLimitStyle() {
125:                return DB.LIMIT_STYLE_POSTGRES;
126:            }
127:
128:            /**
129:             * Return true for PostgreSQL
130:             * @see org.apache.torque.adapter.AbstractDBAdapter#supportsNativeLimit()
131:             */
132:            public boolean supportsNativeLimit() {
133:                return true;
134:            }
135:
136:            /**
137:             * Return true for PostgreSQL
138:             * @see org.apache.torque.adapter.AbstractDBAdapter#supportsNativeOffset()
139:             */
140:            public boolean supportsNativeOffset() {
141:                return true;
142:            }
143:
144:            /**
145:             * Generate a LIMIT limit OFFSET offset clause if offset &gt; 0
146:             * or an LIMIT limit clause if limit is &gt; 0 and offset
147:             * is 0.
148:             *
149:             * @param query The query to modify
150:             * @param offset the offset Value
151:             * @param limit the limit Value
152:             */
153:            public void generateLimits(Query query, int offset, int limit) {
154:                if (offset > 0) {
155:                    query.setOffset(Integer.toString(offset));
156:                }
157:                if (limit >= 0) {
158:                    query.setLimit(Integer.toString(limit));
159:                }
160:
161:                query.setPreLimit(null);
162:                query.setPostLimit(null);
163:            }
164:
165:            /**
166:             * Override the default behavior to associate b with null?
167:             *
168:             * @see DB#getBooleanString(Boolean)
169:             */
170:            public String getBooleanString(Boolean b) {
171:                return (b == null) ? "FALSE" : (Boolean.TRUE.equals(b) ? "TRUE"
172:                        : "FALSE");
173:            }
174:
175:            /**
176:             * This method overrides the JDBC escapes used to format dates
177:             * using a <code>DateFormat</code>.
178:             *
179:             * This generates the timedate format defined in
180:             * http://www.postgresql.org/docs/7.3/static/datatype-datetime.html
181:             * which defined PostgreSQL dates as YYYY-MM-DD hh:mm:ss
182:             * @param date the date to format
183:             * @return The properly formatted date String.
184:             */
185:            public String getDateString(Date date) {
186:                DateFormat df = new SimpleDateFormat(DATE_FORMAT);
187:                StringBuffer dateBuf = new StringBuffer();
188:                char delim = getStringDelimiter();
189:                dateBuf.append(delim);
190:                dateBuf.append(df.format(date));
191:                dateBuf.append(delim);
192:                return dateBuf.toString();
193:            }
194:
195:            /**
196:             * Whether ILIKE should be used for case insensitive like clauses.
197:             *
198:             * As postgres uses ILIKE, this mimplementation returns true.
199:             *
200:             * @return true if ilike should be used for case insensitive likes,
201:             *         false if ignoreCase should be applied to the compared strings.
202:             */
203:            public boolean useIlike() {
204:                return true;
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.