01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.dbplatform;
17:
18: import org.apache.ojb.broker.query.Criteria;
19: import org.kuali.core.dao.jdbc.KualiDBPlatformBase;
20:
21: /**
22: * This class is just for MySQL DB code - should be used only as last resort
23: */
24: public class KualiDBPlatformMySQL extends KualiDBPlatformBase implements
25: KualiDBPlatform {
26: public void applyLimit(Integer limit, Criteria criteria) {
27: if (limit != null) {
28: criteria.addSql(" 1 LIMIT 0," + limit.intValue()); // 1 has to be there because the criteria is ANDed
29: }
30: }
31:
32: public Long getNextAvailableSequenceNumber(String sequenceName) {
33: getJdbcTemplate().execute(
34: new StringBuffer("INSERT INTO ").append(sequenceName)
35: .append(" VALUES (NULL)").toString());
36: return getJdbcTemplate()
37: .queryForLong("SELECT LAST_INSERT_ID()");
38: }
39:
40: public String getStrToDateFunction() {
41: return "STR_TO_DATE";
42: }
43:
44: public String getUpperCaseFunction() {
45: return "UPPER";
46: }
47:
48: public String getDateFormatString(String dateFormatString) {
49: String newString = "";
50: if ("yyyy-mm-dd".equalsIgnoreCase(dateFormatString)) {
51: newString = "'%Y-%m-%d'";
52: } else if ("DD/MM/YYYY HH12:MI:SS PM"
53: .equalsIgnoreCase(dateFormatString)) {
54: newString = "'%d/%m/%Y %r'";
55: }
56: return newString;
57: }
58:
59: public String getCurTimeFunction() {
60: return "NOW()";
61: }
62: }
|