commit 67fd52b5dbc18f49551275b0a91da3a49f80811c Author: Avelino Date: Tue Nov 10 06:32:47 2026 +0100 primero diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..9c7983f --- /dev/null +++ b/.classpath @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64a2545 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# Eclipse +.metadata/ +.settings/ +bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..58dfc6c --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + ProyectoPrueba + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/Ficheros/config.properties b/Ficheros/config.properties new file mode 100644 index 0000000..1e50fde --- /dev/null +++ b/Ficheros/config.properties @@ -0,0 +1,5 @@ +# Base de datos +db.driver=com.mysql.cj.jdbc.Driver +db.url=jdbc:mysql://localhost:3306/red_metro_anp?useSSL=false&serverTimezone=Europe/Madrid&allowPublicKeyRetrieval=true +db.user=root +db.password=1234 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..c83bdec --- /dev/null +++ b/pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + Conectores_02 + Conectores_02 + 0.0.1-SNAPSHOT + + + + + com.mysql + mysql-connector-j + 8.3.0 + + + + + src + + + maven-compiler-plugin + 3.13.0 + + + 17 + + + + + \ No newline at end of file diff --git a/src/aadd/palomafp/prueba/anp/Main.java b/src/aadd/palomafp/prueba/anp/Main.java new file mode 100644 index 0000000..c52cd4c --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/Main.java @@ -0,0 +1,25 @@ +package aadd.palomafp.prueba.anp; + +import java.sql.Connection; +import java.sql.SQLException; + +import aadd.palomafp.prueba.anp.conexion.ConexionDB; + +public class Main { + + public static void main(String[] args) { + + try (Connection conexion = ConexionDB.getConexion()) { + + if (conexion != null && !conexion.isClosed()) { + System.out.println("OK: ¡Conexión establecida con éxito con la base de datos!"); + } + + } catch (SQLException e) { + System.err.println("ERROR: No se pudo establecer la conexión."); + e.printStackTrace(); + } + + } + +} diff --git a/src/aadd/palomafp/prueba/anp/conexion/ConexionDB.java b/src/aadd/palomafp/prueba/anp/conexion/ConexionDB.java new file mode 100644 index 0000000..646c234 --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/conexion/ConexionDB.java @@ -0,0 +1,24 @@ +package aadd.palomafp.prueba.anp.conexion; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +public class ConexionDB { + + public static Connection getConexion() throws SQLException { + + try { + Class.forName(ConfigConexion.get("db.driver")); + + return DriverManager.getConnection( + ConfigConexion.get("db.url"), + ConfigConexion.get("db.user"), + ConfigConexion.get("db.password") + ); + + } catch (ClassNotFoundException e) { + throw new SQLException("No se ha encontrado el driver de la base de datos", e); + } + } +} diff --git a/src/aadd/palomafp/prueba/anp/conexion/ConfigConexion.java b/src/aadd/palomafp/prueba/anp/conexion/ConfigConexion.java new file mode 100644 index 0000000..c33b149 --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/conexion/ConfigConexion.java @@ -0,0 +1,30 @@ +package aadd.palomafp.prueba.anp.conexion; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + + +public class ConfigConexion { + + private static final String RUTA_CONFIG = "ficheros/config.properties"; + private static final Properties PROPS = new Properties(); + + static { + try (FileInputStream fis = new FileInputStream(RUTA_CONFIG)) { + PROPS.load(fis); + } catch (IOException e) { + throw new IllegalStateException("No se pudo leer" + RUTA_CONFIG, e); + } + } + + private ConfigConexion() {} + public static String get(String clave) { + String valor = PROPS.getProperty(clave); + if (valor == null) { + System.out.println("Falta la propiedad: " + clave); + } + + return valor; + } +} diff --git a/src/aadd/palomafp/prueba/anp/dao/PruebaDAO.java b/src/aadd/palomafp/prueba/anp/dao/PruebaDAO.java new file mode 100644 index 0000000..d9d95fe --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/dao/PruebaDAO.java @@ -0,0 +1,5 @@ +package aadd.palomafp.prueba.anp.dao; + +public interface PruebaDAO { + +} diff --git a/src/aadd/palomafp/prueba/anp/dao/impl/Prueba.java b/src/aadd/palomafp/prueba/anp/dao/impl/Prueba.java new file mode 100644 index 0000000..cf1c34b --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/dao/impl/Prueba.java @@ -0,0 +1,7 @@ +package aadd.palomafp.prueba.anp.dao.impl; + +import aadd.palomafp.prueba.anp.dao.PruebaDAO; + +public class Prueba implements PruebaDAO { + +} diff --git a/src/aadd/palomafp/prueba/anp/exception/prueba.java b/src/aadd/palomafp/prueba/anp/exception/prueba.java new file mode 100644 index 0000000..d665ce3 --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/exception/prueba.java @@ -0,0 +1,6 @@ +package aadd.palomafp.prueba.anp.exception; + +public class prueba extends Exception { + + private static final long serialVersionUID = 1L; +} diff --git a/src/aadd/palomafp/prueba/anp/fichero/Prueba.java b/src/aadd/palomafp/prueba/anp/fichero/Prueba.java new file mode 100644 index 0000000..4c3bb10 --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/fichero/Prueba.java @@ -0,0 +1,5 @@ +package aadd.palomafp.prueba.anp.fichero; + +public class Prueba { + +} diff --git a/src/aadd/palomafp/prueba/anp/model/Prueba.java b/src/aadd/palomafp/prueba/anp/model/Prueba.java new file mode 100644 index 0000000..bc87d97 --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/model/Prueba.java @@ -0,0 +1,5 @@ +package aadd.palomafp.prueba.anp.model; + +public class Prueba { + +} diff --git a/src/aadd/palomafp/prueba/anp/service/PruebaService.java b/src/aadd/palomafp/prueba/anp/service/PruebaService.java new file mode 100644 index 0000000..37fbc42 --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/service/PruebaService.java @@ -0,0 +1,5 @@ +package aadd.palomafp.prueba.anp.service; + +public interface PruebaService { + +} diff --git a/src/aadd/palomafp/prueba/anp/service/impl/Prueba.java b/src/aadd/palomafp/prueba/anp/service/impl/Prueba.java new file mode 100644 index 0000000..6f7ad7c --- /dev/null +++ b/src/aadd/palomafp/prueba/anp/service/impl/Prueba.java @@ -0,0 +1,7 @@ +package aadd.palomafp.prueba.anp.service.impl; + +import aadd.palomafp.prueba.anp.service.PruebaService; + +public class Prueba implements PruebaService { + +} diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..9bdf3b1 --- /dev/null +++ b/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Build-Jdk-Spec: 21 +Created-By: Maven Integration for Eclipse + diff --git a/target/classes/META-INF/maven/Conectores_02/Conectores_02/pom.properties b/target/classes/META-INF/maven/Conectores_02/Conectores_02/pom.properties new file mode 100644 index 0000000..7e62192 --- /dev/null +++ b/target/classes/META-INF/maven/Conectores_02/Conectores_02/pom.properties @@ -0,0 +1,7 @@ +#Generated by Maven Integration for Eclipse +#Tue Nov 10 06:31:08 CET 2026 +artifactId=Conectores_02 +groupId=Conectores_02 +m2e.projectLocation=C\:\\Users\\PC GAMING\\eclipse-workspace\\ProyectoPrueba +m2e.projectName=ProyectoPrueba +version=0.0.1-SNAPSHOT diff --git a/target/classes/META-INF/maven/Conectores_02/Conectores_02/pom.xml b/target/classes/META-INF/maven/Conectores_02/Conectores_02/pom.xml new file mode 100644 index 0000000..c83bdec --- /dev/null +++ b/target/classes/META-INF/maven/Conectores_02/Conectores_02/pom.xml @@ -0,0 +1,29 @@ + + 4.0.0 + Conectores_02 + Conectores_02 + 0.0.1-SNAPSHOT + + + + + com.mysql + mysql-connector-j + 8.3.0 + + + + + src + + + maven-compiler-plugin + 3.13.0 + + + 17 + + + + + \ No newline at end of file diff --git a/target/classes/aadd/palomafp/prueba/anp/Main.class b/target/classes/aadd/palomafp/prueba/anp/Main.class new file mode 100644 index 0000000..6053f1c Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/Main.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/conexion/ConexionDB.class b/target/classes/aadd/palomafp/prueba/anp/conexion/ConexionDB.class new file mode 100644 index 0000000..add4a2e Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/conexion/ConexionDB.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/conexion/ConfigConexion.class b/target/classes/aadd/palomafp/prueba/anp/conexion/ConfigConexion.class new file mode 100644 index 0000000..fbb0422 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/conexion/ConfigConexion.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/dao/PruebaDAO.class b/target/classes/aadd/palomafp/prueba/anp/dao/PruebaDAO.class new file mode 100644 index 0000000..0a36d81 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/dao/PruebaDAO.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/dao/impl/Prueba.class b/target/classes/aadd/palomafp/prueba/anp/dao/impl/Prueba.class new file mode 100644 index 0000000..58ec777 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/dao/impl/Prueba.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/exception/prueba.class b/target/classes/aadd/palomafp/prueba/anp/exception/prueba.class new file mode 100644 index 0000000..e5023a4 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/exception/prueba.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/fichero/Prueba.class b/target/classes/aadd/palomafp/prueba/anp/fichero/Prueba.class new file mode 100644 index 0000000..dea2d7e Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/fichero/Prueba.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/model/Prueba.class b/target/classes/aadd/palomafp/prueba/anp/model/Prueba.class new file mode 100644 index 0000000..b758716 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/model/Prueba.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/service/PruebaService.class b/target/classes/aadd/palomafp/prueba/anp/service/PruebaService.class new file mode 100644 index 0000000..38a31a1 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/service/PruebaService.class differ diff --git a/target/classes/aadd/palomafp/prueba/anp/service/impl/Prueba.class b/target/classes/aadd/palomafp/prueba/anp/service/impl/Prueba.class new file mode 100644 index 0000000..0af8414 Binary files /dev/null and b/target/classes/aadd/palomafp/prueba/anp/service/impl/Prueba.class differ