Source Code Cross Referenced for PlatformSapdbImpl.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » platforms » 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 » db ojb » org.apache.ojb.broker.platforms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.broker.platforms;
002:
003:        /* Copyright 2002-2005 The Apache Software Foundation
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        import java.sql.PreparedStatement;
019:        import java.sql.SQLException;
020:        import java.sql.Types;
021:        import java.util.Properties;
022:
023:        import org.apache.ojb.broker.util.sequence.SequenceManagerHelper;
024:
025:        /**
026:         * SapDB specific Platform implementation.
027:         *
028:         * <p/>
029:         * Many of the database sequence specific properties can be specified using
030:         * <em>custom attributes</em> within the <em>sequence-manager</em> element.
031:         * <br/>
032:         * The database sequence specific properties are generally speaking, see database user guide
033:         * for detailed description.
034:         *
035:         * <p>
036:         * Implementation configuration properties:
037:         * </p>
038:         *
039:         * <table cellspacing="2" cellpadding="2" border="3" frame="box">
040:         * <tr>
041:         *     <td><strong>Property Key</strong></td>
042:         *     <td><strong>Property Values</strong></td>
043:         * </tr>
044:         * <tr>
045:         *     <td>sequenceStart</td>
046:         *     <td>
047:         *          DEPRECATED. Database sequence specific property.<br/>
048:         *          Specifies the first sequence number to be
049:         *          generated. Allowed: <em>1</em> or greater.
050:         *    </td>
051:         * </tr>
052:         * <tr>
053:         *     <td>seq.start</td>
054:         *     <td>
055:         *          Database sequence specific property.<br/>
056:         *          Specifies the first sequence number to be
057:         *          generated. Allowed: <em>1</em> or greater.
058:         *    </td>
059:         * </tr>
060:         * <tr>
061:         *     <td>seq.incrementBy</td>
062:         *     <td>
063:         *          Database sequence specific property.<br/>
064:         *          Specifies the interval between sequence numbers.
065:         *          This value can be any positive or negative
066:         *          integer, but it cannot be 0.
067:         *    </td>
068:         * </tr>
069:         * <tr>
070:         *     <td>seq.maxValue</td>
071:         *     <td>
072:         *          Database sequence specific property.<br/>
073:         *          Set max value for sequence numbers.
074:         *    </td>
075:         * </tr>
076:         * <tr>
077:         *     <td>seq.minValue</td>
078:         *     <td>
079:         *          Database sequence specific property.<br/>
080:         *          Set min value for sequence numbers.
081:         *    </td>
082:         * </tr>
083:         * <tr>
084:         *     <td>seq.cycle</td>
085:         *     <td>
086:         *          Database sequence specific property.<br/>
087:         *          If <em>true</em>, specifies that the sequence continues to generate
088:         *          values after reaching either its maximum or minimum value.
089:         *          <br/>
090:         *          If <em>false</em>, specifies that the sequence cannot generate more values after
091:         *          reaching its maximum or minimum value.
092:         *    </td>
093:         * </tr>
094:         * <tr>
095:         *     <td>seq.cache</td>
096:         *     <td>
097:         *          Database sequence specific property.<br/>
098:         *          Specifies how many values of the sequence Oracle
099:         *          preallocates and keeps in memory for faster access.
100:         *          Allowed values: <em>2</em> or greater. If set <em>0</em>,
101:         *          an explicite <em>nocache</em> expression will be set.
102:         *    </td>
103:         * </tr>
104:         * <tr>
105:         *     <td>seq.order</td>
106:         *     <td>
107:         *          Database sequence specific property.<br/>
108:         *          If set <em>true</em>, guarantees that sequence numbers
109:         *          are generated in order of request.
110:         *          <br/>
111:         *          If <em>false</em>, a <em>no order</em> expression will be set.
112:         *    </td>
113:         * </tr>
114:         * </table>
115:         *
116:         * @author Justin A. Stanczak
117:         * @author Matthew Baird (mattb
118:         * @version $Id: PlatformSapdbImpl.java,v 1.10.2.3 2005/12/21 22:26:39 tomdz Exp $
119:         */
120:        public class PlatformSapdbImpl extends PlatformDefaultImpl {
121:            public void setObjectForStatement(PreparedStatement ps, int index,
122:                    Object value, int sqlType) throws SQLException {
123:                if (((sqlType == Types.VARBINARY) || (sqlType == Types.LONGVARBINARY))
124:                        && (value instanceof  byte[])) {
125:                    byte buf[] = (byte[]) value;
126:                    ps.setBytes(index, buf);
127:                } else {
128:                    super .setObjectForStatement(ps, index, value, sqlType);
129:                }
130:            }
131:
132:            /**
133:             * Get join syntax type for this RDBMS - one on of the constants from JoinSyntaxType interface
134:             */
135:            public byte getJoinSyntaxType() {
136:                return ORACLE_JOIN_SYNTAX;
137:            }
138:
139:            /**
140:             * Override default ResultSet size determination (rs.last();rs.getRow())
141:             * with select count(*) operation
142:             * SAP db doesn't let you use the .last, .getRow() mechanism (.getRow() will return -1)
143:             */
144:            public boolean useCountForResultsetSize() {
145:                return true;
146:            }
147:
148:            public String createSequenceQuery(String sequenceName) {
149:                return "CREATE SEQUENCE " + sequenceName;
150:            }
151:
152:            public String createSequenceQuery(String sequenceName,
153:                    Properties prop) {
154:                /*
155:                CREATE SEQUENCE [<schema_name>.]<sequence_name>
156:                    [INCREMENT BY <integer>]
157:                    [START WITH <integer>]
158:                    [MAXVALUE <integer> | NOMAXVALUE]
159:                    [MINVALUE <integer> | NOMINVALUE]
160:                    [CYCLE | NOCYCLE]
161:                    [CACHE <unsigned_integer> | NOCACHE]
162:                    [ORDER|NOORDER]
163:                 */
164:                StringBuffer query = new StringBuffer(
165:                        createSequenceQuery(sequenceName));
166:                if (prop != null) {
167:                    Boolean b;
168:                    Long value;
169:
170:                    value = SequenceManagerHelper.getSeqIncrementBy(prop);
171:                    if (value != null) {
172:                        query.append(" INCREMENT BY ")
173:                                .append(value.longValue());
174:                    }
175:
176:                    value = SequenceManagerHelper.getSeqStart(prop);
177:                    if (value != null) {
178:                        query.append(" START WITH ").append(value.longValue());
179:                    }
180:
181:                    value = SequenceManagerHelper.getSeqMaxValue(prop);
182:                    if (value != null) {
183:                        query.append(" MAXVALUE ").append(value.longValue());
184:                    }
185:
186:                    value = SequenceManagerHelper.getSeqMinValue(prop);
187:                    if (value != null) {
188:                        query.append(" MINVALUE ").append(value.longValue());
189:                    }
190:
191:                    b = SequenceManagerHelper.getSeqCycleValue(prop);
192:                    if (b != null) {
193:                        if (b.booleanValue())
194:                            query.append(" CYCLE");
195:                        else
196:                            query.append(" NOCYCLE");
197:                    }
198:
199:                    value = SequenceManagerHelper.getSeqCacheValue(prop);
200:                    if (value != null) {
201:                        query.append(" CACHE ").append(value.longValue());
202:                    }
203:
204:                    b = SequenceManagerHelper.getSeqOrderValue(prop);
205:                    if (b != null) {
206:                        if (b.booleanValue())
207:                            query.append(" ORDER");
208:                        else
209:                            query.append(" NOORDER");
210:                    }
211:                }
212:                return query.toString();
213:            }
214:
215:            public String nextSequenceQuery(String sequenceName) {
216:                return "select " + sequenceName + ".nextval from dual";
217:            }
218:
219:            public String dropSequenceQuery(String sequenceName) {
220:                return "drop sequence " + sequenceName;
221:            }
222:
223:            /* (non-Javadoc)
224:             * @see org.apache.ojb.broker.platforms.Platform#addPagingSql(java.lang.StringBuffer)
225:             */
226:            public void addPagingSql(StringBuffer anSqlString) {
227:                anSqlString.append(" ROWNO <= ? ");
228:            }
229:
230:            /* (non-Javadoc)
231:             * @see org.apache.ojb.broker.platforms.Platform#bindPagingParameters(java.sql.PreparedStatement, int, int, int)
232:             */
233:            public int bindPagingParameters(PreparedStatement ps, int index,
234:                    int startAt, int endAt) throws SQLException {
235:
236:                ps.setInt(index, endAt - 1); // IGNORE startAt !!
237:                index++;
238:                return index;
239:            }
240:
241:            /* (non-Javadoc)
242:             * @see org.apache.ojb.broker.platforms.Platform#supportsPaging()
243:             */
244:            public boolean supportsPaging() {
245:                return true;
246:            }
247:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.