01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.database.platform;
18:
19: import java.sql.Connection;
20: import java.sql.PreparedStatement;
21: import java.sql.ResultSet;
22: import java.sql.SQLException;
23:
24: import org.apache.ojb.broker.PersistenceBroker;
25: import org.apache.ojb.broker.accesslayer.LookupException;
26:
27: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
28:
29: /**
30: * Platform implementation that generates Mckoi-compliant SQL
31: * @author arh14 at cornell dot edu
32: */
33: public class MckoiPlatform extends ANSISqlPlatform {
34:
35: public String getLockRouteHeaderQuerySQL(Long routeHeaderId,
36: boolean wait) {
37: return "SELECT DOC_HDR_ID FROM EN_DOC_HDR_T WHERE DOC_HDR_ID=?";
38: }
39:
40: public Long getNextValSQL(String sequenceName,
41: PersistenceBroker persistenceBroker) {
42: PreparedStatement statement = null;
43: ResultSet resultSet = null;
44: try {
45: Connection connection = persistenceBroker
46: .serviceConnectionManager().getConnection();
47: statement = connection
48: .prepareStatement("select * NEXTVAL('"
49: + sequenceName + "');");
50: resultSet = statement.executeQuery();
51: if (!resultSet.next()) {
52: throw new WorkflowRuntimeException(
53: "Error retrieving next option id for action list from sequence.");
54: }
55: return new Long(resultSet.getLong(1));
56: } catch (SQLException e) {
57: throw new WorkflowRuntimeException(
58: "Error retrieving next option id for action list from sequence.",
59: e);
60: } catch (LookupException e) {
61: throw new WorkflowRuntimeException(
62: "Error retrieving next option id for action list from sequence.",
63: e);
64: } finally {
65: if (statement != null) {
66: try {
67: statement.close();
68: } catch (SQLException e) {
69: }
70: }
71: if (resultSet != null) {
72: try {
73: resultSet.close();
74: } catch (SQLException e) {
75: }
76: }
77: }
78: }
79:
80: public String toString() {
81: return "[MckoiPlatform]";
82: }
83: }
|