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 org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
019
020 import java.sql.Connection;
021 import java.sql.SQLException;
022 import java.sql.Statement;
023
024 /**
025 * This class is a concrete implementation of <code>Platform</code>.
026 * Provides an implementation for Sybase ASA.
027 * <br/>
028 * This class extends {@link PlatformSybaseImpl} and defines specific
029 * behavior for the Sybase ASA platform.
030 *
031 * <br/>NOTE: Different than the Sybase ASE platform
032 * <br/> Modified by Nicus for Sybase ASA
033 * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird<a>
034 * @version $Id: PlatformSybaseASAImpl.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
035 */
036 public class PlatformSybaseASAImpl extends PlatformSybaseImpl
037 {
038 /**
039 * Sybase Adaptive Server Enterprise (ASE) support timestamp to a precision of 1/300th of second.
040 * Adaptive Server Anywhere (ASA) support timestamp to a precision of 1/1000000tho of second.
041 * Sybase JDBC driver (JConnect) retrieving timestamp always rounds to 1/300th sec., causing rounding
042 * problems with ASA when retrieving Timestamp fields.
043 * This work around was suggested by Sybase Support. Unfortunately it works only with ASA.
044 * <br/>
045 * author Lorenzo Nicora
046 */
047 public void initializeJdbcConnection(JdbcConnectionDescriptor jcd, Connection conn) throws PlatformException
048 {
049 // Do origial init
050 super.initializeJdbcConnection(jcd, conn);
051 // Execute a statement setting the tempory option
052 try
053 {
054 Statement stmt = conn.createStatement();
055 stmt.executeUpdate("set temporary option RETURN_DATE_TIME_AS_STRING = On");
056 }
057 catch (SQLException e)
058 {
059 throw new PlatformException(e);
060 }
061 }
062
063 }