01: package org.apache.ojb.broker.platforms;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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:
18: import java.sql.PreparedStatement;
19: import java.sql.SQLException;
20: import java.sql.Types;
21:
22: /**
23: * This class defines specific behavior for the Derby platform.
24: */
25: public class PlatformDerbyImpl extends PlatformDefaultImpl {
26: /**
27: * {@inheritDoc}
28: */
29: public byte getJoinSyntaxType() {
30: return SQL92_NOPAREN_JOIN_SYNTAX;
31: }
32:
33: /**
34: * {@inheritDoc}
35: */
36: public boolean supportsMultiColumnCountDistinct() {
37: // Currently Derby supports COUNT DISTINCT only for one column
38: return false;
39: }
40:
41: /**
42: * {@inheritDoc}
43: */
44: public void setObjectForStatement(PreparedStatement ps, int index,
45: Object value, int jdbcType) throws SQLException {
46: if (((jdbcType == Types.CHAR) || (jdbcType == Types.VARCHAR))
47: && (value instanceof Character)) {
48: // [tomdz]
49: // Currently, Derby doesn't like Character objects in the PreparedStatement
50: // when using PreparedStatement#setObject(index, value, jdbcType) method
51: // (see issue DERBY-773)
52: // So we make a String object out of the Character object and use that instead
53: super .setObjectForStatement(ps, index, value.toString(),
54: jdbcType);
55: } else {
56: super .setObjectForStatement(ps, index, value, jdbcType);
57: }
58: }
59:
60: /**
61: * {@inheritDoc}
62: */
63: public String getLastInsertIdentityQuery(String tableName) {
64: // matthias.roth@impart.ch
65: // the function is used by the org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl
66: // this call must be made before commit the insert command, so you
67: // must turn off autocommit by seting the useAutoCommit="2"
68: // or use useAutoCommit="1" or use a connection with autoCommit set false
69: // by default (e.g. in managed environments)
70: // transaction demarcation is mandatory
71: return "values IDENTITY_VAL_LOCAL()";
72: }
73: }
|