comentarios service

This commit is contained in:
Isidoro Nevares Martín
2026-11-09 13:06:49 +01:00
parent fd32dc19c3
commit dbd7497d8e
5 changed files with 12 additions and 16 deletions
@@ -15,11 +15,11 @@ import java.sql.SQLException;
*
*/
public class GestorConexionesBBDD {
public class GestorConexionesJDBC {
// Constructor privado: de esta manera conseguimos que esta clase no se puede
// instanciar.
private GestorConexionesBBDD() {
private GestorConexionesJDBC() {
}
public static Connection obtenerConexion() throws SQLException {
@@ -41,10 +41,6 @@ public class GestorConfiguracion {
}
}
public static String getClaseDriver() {
return PROPIEDADES_CONFIGURACION.getProperty("sgdb.clase.driver");
}
public static String getConexionURL() {
return PROPIEDADES_CONFIGURACION.getProperty("sgdb.conexion.url");
}
@@ -6,7 +6,7 @@ import java.sql.SQLException;
import es.madrid.redmetro.eva1.dao.ICocheraDAO;
import es.madrid.redmetro.eva1.dao.impl.CocheraDaoJDBC;
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
import es.madrid.redmetro.eva1.gestores.GestorConexionesBBDD;
import es.madrid.redmetro.eva1.gestores.GestorConexionesJDBC;
import es.madrid.redmetro.eva1.model.Cochera;
/**
@@ -23,7 +23,7 @@ public class CocheraService {
public boolean existeCocheraPorClave(int idCochera) throws RedMetroException {
boolean existeFP = false;
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
existeFP = iCocheraDAO.existeCochera(idCochera);
} catch (SQLException e) {
@@ -34,7 +34,7 @@ public class CocheraService {
public void insertarCochera(Cochera cochera) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
iCocheraDAO.insertarCochera(cochera);
} catch (SQLException e) {
@@ -44,7 +44,7 @@ public class CocheraService {
public void actualizarCochera(Cochera cochera) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
iCocheraDAO.actualizarCochera(cochera);
} catch (SQLException e) {
@@ -54,7 +54,7 @@ public class CocheraService {
public void borrarCochera(int idCochera) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ICocheraDAO iCocheraDAO = new CocheraDaoJDBC(conexion);
iCocheraDAO.borrarCochera(idCochera);
} catch (SQLException e) {
@@ -6,7 +6,7 @@ import java.sql.SQLException;
import es.madrid.redmetro.eva1.dao.ILineaDAO;
import es.madrid.redmetro.eva1.dao.impl.LineaDaoJDBC;
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
import es.madrid.redmetro.eva1.gestores.GestorConexionesBBDD;
import es.madrid.redmetro.eva1.gestores.GestorConexionesJDBC;
import es.madrid.redmetro.eva1.model.Linea;
/**
@@ -22,7 +22,7 @@ public class LineaService {
public Linea obtenerLineaPorClave(int idLinea) throws RedMetroException {
Linea linea = null;
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ILineaDAO iLineaDAO = new LineaDaoJDBC(conexion);
linea = iLineaDAO.obtenerInformacionLinea(idLinea);
} catch (SQLException e) {
@@ -7,7 +7,7 @@ import java.util.List;
import es.madrid.redmetro.eva1.dao.ITrenDAO;
import es.madrid.redmetro.eva1.dao.impl.TrenDaoJDBC;
import es.madrid.redmetro.eva1.excepcion.RedMetroException;
import es.madrid.redmetro.eva1.gestores.GestorConexionesBBDD;
import es.madrid.redmetro.eva1.gestores.GestorConexionesJDBC;
import es.madrid.redmetro.eva1.model.Tren;
/**
@@ -23,7 +23,7 @@ public class TrenService {
public List<Tren> obtenerListaTrenes() throws RedMetroException {
List<Tren> listaTrenes = null;
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ITrenDAO iTrenDAO = new TrenDaoJDBC(conexion);
listaTrenes = iTrenDAO.obtenerListaTrenes();
} catch (SQLException e) {
@@ -34,7 +34,7 @@ public class TrenService {
public void insertarTren(Tren tren) throws RedMetroException {
try (Connection conexion = GestorConexionesBBDD.obtenerConexion();) {
try (Connection conexion = GestorConexionesJDBC.obtenerConexion();) {
ITrenDAO iTrenDAO = new TrenDaoJDBC(conexion);
iTrenDAO.insertarTren(tren);
} catch (SQLException e) {