001/* 002 * Copyright 2018 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.contentio.synchronize.impl.typehandler; 017 018import java.sql.CallableStatement; 019import java.sql.PreparedStatement; 020import java.sql.ResultSet; 021import java.sql.SQLException; 022 023import org.apache.ibatis.type.BaseTypeHandler; 024import org.apache.ibatis.type.JdbcType; 025 026/** 027 * Handle Float SQL types to return Double value 028 */ 029public class SQLDoubleTypeHandler extends BaseTypeHandler<Object> 030{ 031 @Override 032 public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException 033 { 034 ps.setObject(i, parameter); 035 } 036 037 @Override 038 public Object getNullableResult(ResultSet rs, String columnName) throws SQLException 039 { 040 return rs.getDouble(columnName); 041 } 042 043 @Override 044 public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException 045 { 046 return rs.getDouble(columnIndex); 047 048 } 049 050 @Override 051 public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException 052 { 053 return cs.getDouble(columnIndex); 054 } 055}