Muy buenas!!!
Necesitas una  clase que carge tu configuración. Te
mando el código de la mía con la que realizo las
transacciones. Lo único que tienes que hacer es
extender a la que te mando y utilizar los métodos de
la superclase, o  sea, los de mi clase abstracta,
desde la subclase.
public class AbstractUnafeDAO implements IUnafeDAO {
        public static int INSERT_BATCH = 0;
        public static int DELETE_BATCH = 1;
        public static int UPDATE_BATCH = 2;
        
        private static Log log =
LogFactory.getLog(AbstractUnafeDAO.class);
        private static SqlMapClient sqlMap = null;

        static {
                // CARGA ESTATICA DE LOS PARAMETROS
                try {
                        String resource =
"com/unafe/dao/conf/sql-map-config.xml";
                        Reader reader =
Resources.getResourceAsReader(resource);
                        sqlMap =
SqlMapClientBuilder.buildSqlMapClient(reader);
                        reader.close();
                } catch (Exception ex) {
                        log.error("AbstractUnafeDAO static block: " + ex);
                        throw new RuntimeException("Error Initializing
AbstractUnafeDAO :" + ex);
                }               
        }

        public final List getList(String statementName,
Object parameterObject) throws SQLException {
                List list = null;

                try {
                        sqlMap.startTransaction();
                        list = sqlMap.queryForList(statementName,
parameterObject);
                        sqlMap.commitTransaction();
                } catch (SQLException e) {
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                log.error("AbstractUnafeDAO
getList.endTransaction: " + ex);
                                throw ex;
                        }
                        log.error("AbstractUnafeDAO
getList.commitTransaction: " + e);
                        throw e;
                }

                return list;
        }

        public final Object getObject(String statementName,
Object parameterObject) throws SQLException {
                Object result = null;

                try {
                        sqlMap.startTransaction();
                        result = sqlMap.queryForObject(statementName,
parameterObject);
                        sqlMap.commitTransaction();
                } catch (SQLException e) {
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                log.error("AbstractUnafeDAO
getObject.endTransaction: " + ex);
                                throw ex;
                        }
                        log.error("AbstractUnafeDAO
getObject.commitTransaction: " + e);
                        throw e;
                }

                return result;
        }


        public final int update(String statementName, Object
parameterObject) throws SQLException {
                int result = 0;

                try {
                        sqlMap.startTransaction();
                        result = sqlMap.update(statementName,
parameterObject);
                        sqlMap.commitTransaction();
                } catch (SQLException e) {
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                log.error("AbstractUnafeDAO 
update.endTransaction:
" + ex);
                                throw ex;
                        }
                        log.error("AbstractUnafeDAO
update.commitTransaction: " + e);
                        throw e;
                }

                return result;
        }
        
        public final void insert(String statementName, Object
parameterObject) throws SQLException {
                try {
                        sqlMap.startTransaction();
                        sqlMap.insert(statementName, parameterObject);
                        sqlMap.commitTransaction();
                } catch (SQLException e) {
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                log.error("AbstractUnafeDAO 
insert.endTransaction:
" + ex);
                                throw ex;
                        }
                        log.error("AbstractUnafeDAO
insert.commitTransaction: " + e);
                        throw e;
                }
        }       

        public final void delete(String statementName, Object
parameterObject) throws SQLException {
                try {
                        sqlMap.startTransaction();
                        sqlMap.delete(statementName, parameterObject);
                        sqlMap.commitTransaction();
                } catch (SQLException e) {
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                log.error("AbstractUnafeDAO 
delete.endTransaction:
" + ex);
                                throw ex;
                        }
                        log.error("AbstractUnafeDAO
delete.commitTransaction: " + e);
                        throw e;
                }
/*              finally{
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                throw ex;
                        }                       
                }
                */
        }       
        
        public final void executeBatch(int accion, String
statementName, List objs) throws SQLException{
                try {
                        sqlMap.startTransaction();
                        sqlMap.startBatch();
                        for(int i=0;i<objs.size();i++){
                                if(accion==INSERT_BATCH)
                                        sqlMap.insert(statementName, 
objs.get(i));
                                else if(accion==UPDATE_BATCH)
                                        sqlMap.update(statementName, 
objs.get(i));
                                else if(accion==DELETE_BATCH)   
                                        sqlMap.delete(statementName, 
objs.get(i));
                        }
                        sqlMap.executeBatch();
                        sqlMap.commitTransaction();
                } catch (SQLException e) {
                        try {
                                sqlMap.endTransaction();
                        } catch (SQLException ex) {
                                log.error("AbstractUnafeDAO
executeBatch.endTransaction: " + ex);
                                throw ex;
                        }
                        log.error("AbstractUnafeDAO
executeBatch.commitTransaction: " + e);
                        throw e;
                }               
        }
}

Saludos


                
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

Reply via email to