This commit is contained in:
Avelino
2026-11-10 06:32:47 +01:00
commit 67fd52b5db
28 changed files with 240 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
+4
View File
@@ -0,0 +1,4 @@
# Eclipse
.metadata/
.settings/
bin/
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ProyectoPrueba</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+5
View File
@@ -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
+29
View File
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Conectores_02</groupId>
<artifactId>Conectores_02</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- Conector de MySQL JDBC -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.3.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<!-- Cambia esto al número de la versión de Java que tengas instalada (ej: 17, 21, etc.) -->
<release>17</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
+25
View File
@@ -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();
}
}
}
@@ -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);
}
}
}
@@ -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;
}
}
@@ -0,0 +1,5 @@
package aadd.palomafp.prueba.anp.dao;
public interface PruebaDAO {
}
@@ -0,0 +1,7 @@
package aadd.palomafp.prueba.anp.dao.impl;
import aadd.palomafp.prueba.anp.dao.PruebaDAO;
public class Prueba implements PruebaDAO {
}
@@ -0,0 +1,6 @@
package aadd.palomafp.prueba.anp.exception;
public class prueba extends Exception {
private static final long serialVersionUID = 1L;
}
@@ -0,0 +1,5 @@
package aadd.palomafp.prueba.anp.fichero;
public class Prueba {
}
@@ -0,0 +1,5 @@
package aadd.palomafp.prueba.anp.model;
public class Prueba {
}
@@ -0,0 +1,5 @@
package aadd.palomafp.prueba.anp.service;
public interface PruebaService {
}
@@ -0,0 +1,7 @@
package aadd.palomafp.prueba.anp.service.impl;
import aadd.palomafp.prueba.anp.service.PruebaService;
public class Prueba implements PruebaService {
}
+4
View File
@@ -0,0 +1,4 @@
Manifest-Version: 1.0
Build-Jdk-Spec: 21
Created-By: Maven Integration for Eclipse
@@ -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
@@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Conectores_02</groupId>
<artifactId>Conectores_02</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- Conector de MySQL JDBC -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.3.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<!-- Cambia esto al número de la versión de Java que tengas instalada (ej: 17, 21, etc.) -->
<release>17</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Binary file not shown.