1 16 17 package org.springframework.jdbc.core.support; 18 19 import java.sql.PreparedStatement ; 20 import java.sql.SQLException ; 21 22 import org.springframework.dao.DataAccessException; 23 import org.springframework.jdbc.core.PreparedStatementCallback; 24 import org.springframework.jdbc.support.lob.LobCreator; 25 import org.springframework.jdbc.support.lob.LobHandler; 26 27 54 public abstract class AbstractLobCreatingPreparedStatementCallback implements PreparedStatementCallback { 55 56 private final LobHandler lobHandler; 57 58 63 public AbstractLobCreatingPreparedStatementCallback(LobHandler lobHandler) { 64 this.lobHandler = lobHandler; 65 } 66 67 public final Object doInPreparedStatement(PreparedStatement ps) throws SQLException , DataAccessException { 68 LobCreator lobCreator = this.lobHandler.getLobCreator(); 69 try { 70 setValues(ps, lobCreator); 71 return new Integer (ps.executeUpdate()); 72 } 73 finally { 74 lobCreator.close(); 75 } 76 } 77 78 86 protected abstract void setValues(PreparedStatement ps, LobCreator lobCreator) 87 throws SQLException , DataAccessException; 88 89 } 90 | Popular Tags |