diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java index d8a7031fd..514d9996f 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaHibernateDAO.java @@ -175,8 +175,9 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO i } private void gerarSeqNumFolioSistema(Integer idEmpresa) throws RuntimeException { + Connection conn = null; try { - Connection conn = dataSource.getConnection(); + conn = dataSource.getConnection(); if (!conn.createStatement().executeQuery("select SEQUENCE_NAME from DBA_SEQUENCES where SEQUENCE_NAME like 'FOLIO_SISTEMA_" + idEmpresa + "_SEQ%'").next()) { String[] sequences = { "AC", "AL", "AM", "AP", "BA", "CE", "DF", "ES", "GO", "MA", "MG", "MS", "MT", "PA", "PB", "PE", "PI", "PR", "RJ", "RN", "RO", "RR", "RS", "SC", "SE", "SP", "TO" }; @@ -186,6 +187,14 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO i } } catch (SQLException e) { throw new RuntimeException(e); + }finally { + try { + if(conn != null && !conn.isClosed()){ + conn.close(); + } + } catch (SQLException e) { + e.printStackTrace(); + } } }