001/* 002 * Copyright 2002-2013 the original author or authors. 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 * https://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 */ 016 017package org.springframework.jdbc.support.lob; 018 019import java.io.InputStream; 020import java.io.Reader; 021import java.sql.ResultSet; 022import java.sql.SQLException; 023 024/** 025 * Abstract base class for {@link LobHandler} implementations. 026 * 027 * <p>Implements all accessor methods for column names through a column lookup 028 * and delegating to the corresponding accessor that takes a column index. 029 * 030 * @author Juergen Hoeller 031 * @since 1.2 032 * @see java.sql.ResultSet#findColumn 033 */ 034public abstract class AbstractLobHandler implements LobHandler { 035 036 @Override 037 public byte[] getBlobAsBytes(ResultSet rs, String columnName) throws SQLException { 038 return getBlobAsBytes(rs, rs.findColumn(columnName)); 039 } 040 041 @Override 042 public InputStream getBlobAsBinaryStream(ResultSet rs, String columnName) throws SQLException { 043 return getBlobAsBinaryStream(rs, rs.findColumn(columnName)); 044 } 045 046 @Override 047 public String getClobAsString(ResultSet rs, String columnName) throws SQLException { 048 return getClobAsString(rs, rs.findColumn(columnName)); 049 } 050 051 @Override 052 public InputStream getClobAsAsciiStream(ResultSet rs, String columnName) throws SQLException { 053 return getClobAsAsciiStream(rs, rs.findColumn(columnName)); 054 } 055 056 @Override 057 public Reader getClobAsCharacterStream(ResultSet rs, String columnName) throws SQLException { 058 return getClobAsCharacterStream(rs, rs.findColumn(columnName)); 059 } 060 061}