1 4 package org.ofbiz.minerva.pool.jdbc; 5 6 import java.sql.Connection ; 7 import java.sql.PreparedStatement ; 8 import java.sql.SQLException ; 9 10 import org.apache.log4j.Logger; 11 import org.ofbiz.minerva.pool.cache.CachedObjectFactory; 12 13 19 public class PreparedStatementFactory extends CachedObjectFactory { 20 21 private Connection con; 22 private Logger logger = Logger.getLogger(PreparedStatementFactory.class); 23 24 public PreparedStatementFactory(Connection con) { 25 this.con = con; 26 } 27 28 31 public Object createObject(Object sqlString) { 32 String sql = (String ) sqlString; 33 try { 34 return con.prepareStatement(sql); 35 } catch (SQLException e) { 36 logger.warn("Error creating prepared statement.", e); 37 return null; 38 } 39 } 40 41 44 public void deleteObject(Object pooledObject) { 45 try { 46 ((PreparedStatement ) pooledObject).close(); 47 } catch (SQLException e) { 48 } 49 } 50 } 51 | Popular Tags |