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 org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
19:
20: import java.sql.Connection;
21: import java.sql.SQLException;
22: import java.sql.Statement;
23:
24: /**
25: * This class is a concrete implementation of <code>Platform</code>.
26: * Provides an implementation for Sybase ASA.
27: * <br/>
28: * This class extends {@link PlatformSybaseImpl} and defines specific
29: * behavior for the Sybase ASA platform.
30: *
31: * <br/>NOTE: Different than the Sybase ASE platform
32: * <br/> Modified by Nicus for Sybase ASA
33: * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird<a>
34: * @version $Id: PlatformSybaseASAImpl.java,v 1.6.2.1 2005/12/21 22:26:40 tomdz Exp $
35: */
36: public class PlatformSybaseASAImpl extends PlatformSybaseImpl {
37: /**
38: * Sybase Adaptive Server Enterprise (ASE) support timestamp to a precision of 1/300th of second.
39: * Adaptive Server Anywhere (ASA) support timestamp to a precision of 1/1000000tho of second.
40: * Sybase JDBC driver (JConnect) retrieving timestamp always rounds to 1/300th sec., causing rounding
41: * problems with ASA when retrieving Timestamp fields.
42: * This work around was suggested by Sybase Support. Unfortunately it works only with ASA.
43: * <br/>
44: * author Lorenzo Nicora
45: */
46: public void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
47: Connection conn) throws PlatformException {
48: // Do origial init
49: super .initializeJdbcConnection(jcd, conn);
50: // Execute a statement setting the tempory option
51: try {
52: Statement stmt = conn.createStatement();
53: stmt
54: .executeUpdate("set temporary option RETURN_DATE_TIME_AS_STRING = On");
55: } catch (SQLException e) {
56: throw new PlatformException(e);
57: }
58: }
59:
60: }
|