iplementacion

This commit is contained in:
Soka_jplr 2024-05-14 17:46:43 -06:00
parent 014b5df704
commit f433408735
4 changed files with 58 additions and 0 deletions

View File

@ -20,6 +20,12 @@ create table alumno(
correo varchar(40)
);
create table registro(
id integer auto_increment primary key,
matricula varchar(40),
descripcion varchar(100)
);
drop table examen;
create table examen(

View File

@ -1,6 +1,7 @@
package mx.uv.Controller;
import java.sql.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@ -160,6 +161,7 @@ public class DAO {
while (rs.next()) {
alumno = new Alumno(rs.getInt(1), rs.getString(2), rs.getString(3),rs.getString(4), rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8),rs.getString(9));
}
DAORegistro.registrar(alumno," Inicio Sesión ", LocalDateTime.now());
} catch (Exception e) {
System.out.println(e);
} finally {

View File

@ -0,0 +1,45 @@
package mx.uv.Controller;
import java.time.LocalDateTime;
import java.sql.*;
import mx.uv.Model.Alumno;
public class DAORegistro {
private static Conexion cn = Conexion.getInstance();
public static void registrar(Alumno alumno, String descripcion, LocalDateTime day) {
PreparedStatement stm = null;
Connection conn = null;
conn = cn.conectar();
try {
String sql = "INSERT INTO `registro`(`matricula`,`descripcion`)VALUES(?,?);";
stm = (PreparedStatement) conn.prepareStatement(sql);
stm.setString(1, alumno.getMatricula());
stm.setString(2, descripcion + day);
stm.executeUpdate();
} catch (Exception e) {
System.out.println(e);
} finally {
cerrarConexiones(stm,conn);
}
}
private static void cerrarConexiones(PreparedStatement stm,Connection conn) {
if (stm != null) {
try {
stm.close();
} catch (Exception e) {
System.out.println(e);
}
stm = null;
}
try {
conn.close();
cn.cerrarConexion();
} catch (Exception e) {
System.out.println(e);
}
}
}

View File

@ -0,0 +1,5 @@
package mx.uv.Model;
public class Registro {
}