Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class Articulo {
- public int id;
- public String titulo;
- public String contenido;
- public Date fechaP;
- public Date fechaE;
- private transient Conexion conn;
- public Articulo(int i, String t, String c, Date p, Date e) {
- this.id = i;
- this.titulo = t;
- this.contenido = c;
- this.fechaP = p;
- this.fechaE = e;
- }
- public Articulo(Conexion c){
- this.conn = c;
- }
- public boolean setArticulo(Articulo a) {
- int i = a.id;
- String t = a.titulo;
- String c = a.contenido;
- Date fP = a.fechaP;
- Date fE = a.fechaE;
- try {
- String s = "UPDATE articulo SET id = " + i + ", titulo = " + t + ", contenido = " + c + ", fechaPublicacion = " + fP + ", fechaEscritura = " + fE +" WHERE id = " + i;
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) {System.out.println ("Cannot update Articulo" + e); return false;}
- return true;
- }
- public Articulo getArticulo(int id){
- try {
- conn.stmt.executeQuery ("SELECT id, titulo, contenido, fechaPublicacion, FechaEscritura FROM articulo WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- int nArt = rs.getInt ("id");
- String titulo = rs.getString("titulo");
- String contenido = rs.getString("contenido");
- Date fPub = rs.getDate("fechaPub");
- Date fEsc = rs.getDate("fechaEsc");
- rs.close();
- Articulo resultado = new Articulo(nArt, titulo, contenido, fPub, fEsc);
- return( resultado );
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean agregar(int id, String titulo, String contenido, Date fechaPub, Date fechaEsc){
- try {
- String s = "INSERT INTO articulo (id, titulo, contenido, fechaPublicacion, FechaEscritura)" +
- " VALUES ("+ id + " , '" + titulo + " , '" + contenido + "', " + fechaPub + "', " + fechaEsc + " )";
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot update Articulo" + e ); return false;}
- return true;
- }
- public boolean deleteArticulo(int id){
- try {
- String s = "DELETE FROM articulo WHERE id = " + id;
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot delete Articulo" + e ); return false;}
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class Autor {
- public int id;
- public String nombre;
- public Date fechaUltPub;
- private transient Conexion conn;
- public Autor(int i, String nom, Date p) {
- this.id = i;
- this.nombre = nom;
- this.fechaUltPub = p;
- }
- public Autor(Conexion c){
- this.conn = c;
- }
- public boolean setAutor(Autor a) {
- int i;
- String n;
- Date f;
- i = a.id;
- n = a.nombre;
- f = a.fechaUltPub;
- try {
- String s = "UPDATE autor SET id = " + i + ", nombre = " + n + ", fechaUltimaPublicacion = " + f+ " WHERE id = " + i;
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) {System.out.println ("Cannot update Autor" + e); return false;}
- return true;
- }
- public Autor getAutor(int id){
- try {
- conn.stmt.executeQuery ("SELECT id, nombre, fechaUltimaPublicacion FROM autor WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- int nAut = rs.getInt ("id");
- String nom = rs.getString("nombre");
- Date fUltPub = rs.getDate("fechaUltimaPublicacion");
- rs.close();
- Autor resultado = new Autor(nAut, nom, fUltPub);
- return( resultado );
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean agregar(int id, String nom, Date fechaUltPub){
- try {
- String s = "INSERT INTO autor (id, nombre, fechaUltimaPublicacion)" +
- " VALUES ("+ id + " , '" + nom + "', " + fechaUltPub + " )";
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot update Autor" + e ); return false;}
- return true;
- }
- public boolean deleteAutor(int id){
- try {
- String s = "DELETE FROM autor WHERE id = " + id;
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot delete Autor" + e ); return false;}
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- public class AutorArticulo {
- public int idAutor;
- public int idArticulo;
- private transient Conexion conn;
- public AutorArticulo(Conexion co){ this.conn = co; }
- public AutorArticulo(int idAutor, int idArticulo){
- this.idAutor = idAutor;
- this.idArticulo = idArticulo;
- }
- public AutorArticulo getAutorArticulo(int idAutor, int idArticulo){
- try {
- conn.stmt.executeQuery ("SELECT * FROM autorArticulo WHERE idAutor = " + idAutor +" AND idArticulo = "+idArticulo);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.idArticulo = rs.getInt("idArticulo");
- this.idAutor = rs.getInt("idAutor");
- rs.close();
- return(this);
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean addAutorArticulo(AutorArticulo aa){
- try {
- conn.stmt.executeUpdate ("INSERT INTO autorArticulo(idAutor, idArticulo) VALUES('"+aa.idAutor+"','"+aa.idArticulo+"')");
- } catch (SQLException e) {System.out.println ("Cannot getAutorArticulo()" + e);
- return false;
- }
- return true;
- }
- public boolean deleteAutorArticulo(AutorArticulo aa){
- try {
- conn.stmt.executeUpdate ("delete from autorArticulo where idAutor = "+aa.idAutor+" AND idArticulo = "+aa.idArticulo);
- } catch (SQLException e) {System.out.println ("Cannot setAutorArticulo()" + e);
- return false;
- }
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- public class CartaEditorJefe {
- public int id;
- public int idEditorJefe;
- public String contenido;
- private transient Conexion conn;
- public CartaEditorJefe(Conexion conn){ this.conn = conn; }
- public CartaEditorJefe(int id, int idEditorJefe, String contenido){
- this.id = id;
- this.idEditorJefe = idEditorJefe;
- this.contenido = contenido;
- }
- public CartaEditorJefe getCartaEditorJefe(int id){
- try {
- conn.stmt.executeQuery ("SELECT * FROM cartaEditorJefe WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.id = rs.getInt("id");
- this.idEditorJefe = rs.getInt("idEditorJefe");
- this.contenido = rs.getString("contenido");
- rs.close();
- return(this);
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean setCartaEditorJefe(CartaEditorJefe carta){
- try {
- String s = "UPDATE cartaEditorJefe SET idEditorJefe = " + carta.idEditorJefe + ", SET contenido = " + carta.contenido + " WHERE id = " + carta.id;
- conn.stmt.executeUpdate(s);
- } catch (SQLException e) {System.out.println ("Cannot execute disposicion()" + e);
- return false;
- }
- return true;
- }
- public boolean addCartaEditorJefe(CartaEditorJefe carta){
- try {
- conn.stmt.executeUpdate ("INSERT INTO cartaEditorJefe(idEditorJefe, contenido) VALUES('"+carta.idEditorJefe+"','"+carta.contenido+"')");
- } catch (SQLException e) {System.out.println ("Cannot getCartaEditorJefe()" + e);
- return false;
- }
- return true;
- }
- public boolean deleteCartaEditorJefe(CartaEditorJefe carta){
- try {
- conn.stmt.executeUpdate ("delete from cartaEditorJefe where id = "+carta.id);
- } catch (SQLException e) {System.out.println ("Cannot setcartaEditorJefe()" + e);
- return false;
- }
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class Conexion {
- public Connection conn;
- public Statement stmt, stmt2;
- public Conexion(){
- try {
- String userName = "root";
- String password = "";
- String url = "jdbc:mysql://localhost/tec";
- Class.forName ("com.mysql.jdbc.Driver").newInstance();
- conn = DriverManager.getConnection (url, userName, password);
- stmt = conn.createStatement();
- stmt2 = conn.createStatement();
- }catch (Exception e) { System.out.println ("Cannot connect to database server"); }
- }
- }
- package entidades;
- import java.sql.*;
- public class Consejo {
- public int id;
- public String nombre;
- public Date anio;
- private transient Conexion conn;
- public Consejo(Conexion co){
- this.conn = co;
- }
- public Consejo(int id, String nombre, Date anio){
- this.id = id;
- this.nombre = nombre;
- this.anio = anio;
- }
- public Consejo getConsejo(int id){
- try {
- conn.stmt.executeQuery ("SELECT * FROM consejo WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.id = rs.getInt("id");
- this.nombre = rs.getString("nombre");
- this.anio = rs.getDate("anio");
- rs.close();
- return(this);
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean setConsejo(Consejo con){
- try {
- String s = "UPDATE consejo SET nombre = " + con.nombre + ", SET anio = " + con.anio + " WHERE id = " + con.id;
- conn.stmt.executeUpdate(s);
- } catch (SQLException e) {System.out.println ("Cannot execute disposicion()" + e);
- return false;
- }
- return true;
- }
- public boolean addConsejo(Consejo con){
- try {
- conn.stmt.executeUpdate ("INSERT INTO consejo(nombre, anio) VALUES('"+con.nombre+"','"+con.anio+"')");
- } catch (SQLException e) {System.out.println ("Cannot getConsejo()" + e);
- return false;
- }
- return true;
- }
- public boolean deleteConsejo(Consejo con){
- try {
- conn.stmt.executeUpdate ("delete from consejo where id = "+con.id);
- } catch (SQLException e) {System.out.println ("Cannot setConsejo()" + e);
- return false;
- }
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class EditorJefe {
- public int id, idConsejo;
- public String nombre;
- private transient Conexion conn;
- public EditorJefe(Conexion c){
- this.conn = c;
- }
- public EditorJefe(int id, int idConsejo, String nombre) {
- this.id = id;
- this.idConsejo = idConsejo;
- this.nombre = nombre;
- }
- public EditorJefe getEditorJefe(int id) {
- try {
- conn.stmt.executeQuery ("SELECT * FROM editorJefe WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.id = rs.getInt ("id");
- this.idConsejo = rs.getInt ("idConsejo");
- this.nombre = rs.getString ("nombre");
- rs.close();
- return this;
- }else{ return null;}
- }catch (SQLException e) {
- System.out.println(e); return null;
- }
- }
- public boolean setEditorJefe(EditorJefe j) {
- try{
- conn.stmt.executeUpdate ("UPDATE editorJefe SET idConsejo = " + j.idConsejo + ", nombre = " + j.nombre + " WHERE id = " + j.id);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean insertEditorJefe(EditorJefe j) {
- try{
- conn.stmt.executeUpdate ("INSERT INTO editorJefe (idConsejo,nombre) VALUES (" + j.idConsejo + "," + j.nombre + ")");
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean deleteEditorJefe(int id) {
- try{
- conn.stmt.executeUpdate ("DELETE FROM editorJefe WHERE id = " + id);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- }
- package entidades;
- import java.sql.*;
- public class Guru {
- public int id;
- public String nombre;
- private transient Conexion conn;
- public Guru(Conexion co){
- this.conn = co;
- }
- public Guru(int id, String nombre){
- this.id = id;
- this.nombre = nombre;
- }
- public Guru getGuru(int id){
- try {
- conn.stmt.executeQuery ("SELECT * FROM guru WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.id = rs.getInt("id");
- this.nombre = rs.getString("nombre");
- rs.close();
- return(this);
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean setGuru(Guru gur){
- try {
- String s = "UPDATE guru SET nombre = " + gur.nombre + " WHERE id = " + gur.id;
- conn.stmt.executeUpdate(s);
- } catch (SQLException e) {System.out.println ("Cannot execute disposicion()" + e);
- return false;
- }
- return true;
- }
- public boolean addGuru(Guru gur){
- try {
- conn.stmt.executeUpdate ("INSERT INTO guru(nombre) VALUES('"+gur.nombre+")");
- } catch (SQLException e) {System.out.println ("Cannot addGuru()" + e);
- return false;
- }
- return true;
- }
- public boolean deleteGuru(Guru gur){
- try {
- conn.stmt.executeUpdate ("delete from guru where id = "+gur.id);
- } catch (SQLException e) {System.out.println ("Cannot setGuru()" + e);
- return false;
- }
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class Juez {
- public int id, idConsejo;
- public String nombre;
- private transient Conexion conn;
- public Juez(Conexion c){
- this.conn = c;
- }
- public Juez(int id, int idConsejo, String nombre) {
- this.id = id;
- this.idConsejo = idConsejo;
- this.nombre = nombre;
- }
- public Juez getJuez(int id) {
- try {
- conn.stmt.executeQuery ("SELECT * FROM juez WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.id = rs.getInt ("id");
- this.idConsejo = rs.getInt ("idConsejo");
- this.nombre = rs.getString ("nombre");
- rs.close();
- return this;
- }else{ return null;}
- } catch (SQLException e) {
- System.out.println(e); return null;
- }
- }
- public boolean setJuez(Juez j) {
- try{
- conn.stmt.executeUpdate ("UPDATE juez SET idConsejo = " + j.idConsejo + ", nombre = " + j.nombre + " WHERE id = " + j.id);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean insertJuez(Juez j) {
- try{
- conn.stmt.executeUpdate ("INSERT INTO juez (idConsejo,nombre) VALUES (" + j.idConsejo + "," + j.nombre + ")");
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean deleteJuez(int id) {
- try{
- conn.stmt.executeUpdate ("DELETE FROM juez WHERE id = " + id);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- }
- package entidades;
- import java.sql.*;
- public class PublicacionGuru {
- public int idGuru;
- public int idPub;
- public Date fechaEnvio;
- private transient Conexion conn;
- public PublicacionGuru(Conexion conn){ this.conn = conn; }
- public PublicacionGuru(int idGuru, int idPub, Date fechaEnvio){
- this.idGuru = idGuru;
- this.idPub = idPub;
- this.fechaEnvio = fechaEnvio;
- }
- public PublicacionGuru getPublicacionGuru(int idG, int idP){
- String s = "SELECT * FROM guruPub WHERE" +
- " idGuru = " + idG + " and idPub = " + idP;
- try {
- conn.stmt.executeQuery(s);
- ResultSet rs = conn.stmt.getResultSet();
- if(rs.next()){
- this.fechaEnvio = rs.getDate("fechaEnvio");
- }else{
- return null;
- }
- }catch(SQLException e){
- System.out.println(e);
- return null;
- }
- return new PublicacionGuru(idG, idP, this.fechaEnvio);
- }
- public boolean setPublicacionGuru(PublicacionGuru pg){
- String s = "UPDATE guruPub " +
- "SET idGuru = " + pg.idGuru + ", idPub = " + pg.idPub +
- ", fechaEnvio = " + pg.fechaEnvio +
- "WHERE idGuru = " + pg.idGuru + " and idPub = " + pg.idPub;
- try {
- conn.stmt.executeUpdate(s);
- }catch(SQLException e){
- System.out.println(e);
- return false;
- }
- return true;
- }
- public boolean addPublicacionGuru(PublicacionGuru pg){
- String s = "INSERT INTO guruPub " +
- "VALUES (" + pg.idGuru + "," + pg.idPub + "," + pg.fechaEnvio + ") ";
- try {
- conn.stmt.executeUpdate(s);
- }catch(SQLException e){
- System.out.println(e);
- return false;
- }
- return true;
- }
- public boolean deletePublicacionGuru(int idG, int idP){
- String s = "DELETE FROM guruPub " +
- "WHERE idGuru = " + idG + " and idPub = " + idP;
- try {
- conn.stmt.executeUpdate(s);
- }catch(SQLException e){
- System.out.println(e);
- return false;
- }
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class Publicacion {
- public int id;
- public int idJefe;
- public int idCarta;
- private transient Conexion conn;
- public Publicacion(int i, int ij, int ic) {
- this.id = i;
- this.idJefe = ij;
- this.idCarta = ic;
- }
- public Publicacion(Conexion c){
- this.conn = c;
- }
- public boolean setPublicacion(Publicacion a) {
- int i;
- int ij;
- int ic;
- i = a.id;
- ij = a.idJefe;
- ic = a.idCarta;
- try {
- String s = "UPDATE publicacion SET id = " + i + ", idJefe = " + ij + ", idCarta = " + ic + " WHERE id = " + i;
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) {System.out.println ("Cannot update Publicacion" + e); return false;}
- return true;
- }
- public Publicacion getPublicacion(int id){
- try {
- conn.stmt.executeQuery ("SELECT id, idJefe, idCarta FROM publicacion WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- int i = rs.getInt ("id");
- int ij = rs.getInt("idJefe");
- int ic = rs.getInt("idCarta");
- rs.close();
- Publicacion resultado = new Publicacion(i, ij, ic);
- return( resultado );
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean agregar(int id, String nom, Date fechaUltPub){
- try {
- String s = "INSERT INTO publicacion (id, idJefe, idCarta)" +
- " VALUES ("+ id + " , '" + idJefe + "', " + idCarta + " )";
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot update Publiacion" + e ); return false;}
- return true;
- }
- public boolean deletePublicacion(int id){
- try {
- String s = "DELETE FROM publicacion WHERE id = " + id;
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot delete Publiacion" + e ); return false;}
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class PuestoRevistas {
- public int id;
- public String direccion;
- private transient Conexion conn;
- public PuestoRevistas(int i, String d) {
- this.id = i;
- this.direccion = d;
- }
- public PuestoRevistas(Conexion c){
- this.conn = c;
- }
- public boolean setPuestoRevistas(PuestoRevistas a) {
- int i;
- String d;
- i = a.id;
- d = a.direccion;
- try {
- String s = "UPDATE puestoRevistas SET id = " + i + ", direccion = " + d + " WHERE id = " + i;
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) {System.out.println ("Cannot update PuestoRevistas" + e); return false;}
- return true;
- }
- public PuestoRevistas getPuestoRevistas(int id){
- try {
- conn.stmt.executeQuery ("SELECT id, direccion FROM puestoRevistas WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- int i = rs.getInt ("id");
- String d = rs.getString("direccion");
- rs.close();
- PuestoRevistas resultado = new PuestoRevistas(i, d);
- return( resultado );
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e); }
- return null;
- }
- public boolean agregar(int i, String d){
- try {
- String s = "INSERT INTO puestoRevistas (id, direccion)" +
- " VALUES ("+ i + " , '" + d + " )";
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (Exception e) { System.out.println ("Cannot update PuestoRevistas" + e ); return false; }
- return true;
- }
- public boolean deletePuestoRevistas(int id){
- try {
- String s = "DELETE FROM puestoRevistas WHERE id = " + id;
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (Exception e) { System.out.println ("Cannot delete PuestoRevistas" + e ); return false; }
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class PuestoRevistasPub {
- public int idPuesto,idPub,cantidadEnviada,cantidadRegresada;
- public Date fechaEnvio,fechaRegreso;
- private transient Conexion conn;
- public PuestoRevistasPub(Conexion c){
- this.conn = c;
- }
- public PuestoRevistasPub(int idPuesto, int idPub, int cantidadEnviada, int cantidadRegresada, Date fechaRegresada, Date fechaEnvio) {
- this.idPuesto = idPuesto;
- this.idPub = idPub;
- this.fechaEnvio = fechaEnvio;
- this.fechaRegreso = fechaRegreso;
- this.cantidadEnviada = cantidadEnviada;
- this.cantidadRegresada = cantidadRegresada;
- }
- public PuestoRevistasPub getPuestoRevistasPub(int id) {
- try {
- conn.stmt.executeQuery ("SELECT * FROM suscriptorPub WHERE idPuesto = " + idPuesto + " and idPub = " + idPub);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.idPuesto = rs.getInt ("idPuesto");
- this.idPub = rs.getInt ("idPub");
- this.cantidadEnviada = rs.getInt ("cantidadEnviada");
- this.cantidadRegresada = rs.getInt ("cantidadRegresada");
- this.fechaEnvio = rs.getDate ("fechaEnvio");
- this.fechaEnvio = rs.getDate ("fechaRegreso");
- rs.close();
- return this;
- }else{ return null;}
- } catch(SQLException e) {
- System.out.println(e); return null;
- }
- }
- public boolean setPuestoRevistasPub(PuestoRevistasPub j) {
- try{
- conn.stmt.executeUpdate ("UPDATE suscriptorPub SET cantidadEnviada = " + j.cantidadEnviada + ", cantidadRegresada = " + j.cantidadRegresada + " fechaEnvio = " + j.fechaEnvio + " fechaRegreso = " + j.fechaRegreso + " WHERE idPuesto = " + j.idPuesto + " and idPub = " + j.idPub);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean insertPuestoRevistasPub(PuestoRevistasPub j) {
- try{
- conn.stmt.executeUpdate ("INSERT INTO puestoRevistasPub (idPuesto,idPub,cantidadEnviada,cantidadRegresada,fechaRegreso,fechaEnvio) VALUES (" + j.idPuesto + "," + j.idPub + "," + j.cantidadEnviada + "," + j.cantidadRegresada + "," + j.fechaEnvio + "," + j.fechaRegreso + ")");
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean deletePuestoRevistasPub(int idPuesto, int idPub) {
- try{
- conn.stmt.executeUpdate ("DELETE FROM puestoRevistasPub WHERE idPuesto = " + idPuesto + " and idPub = " + idPub);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class Subscriptor {
- public int id;
- public String nombre;
- public String tipo;
- private transient Conexion conn;
- public Subscriptor(int i, String n, String t) {
- this.id = i;
- this.nombre = n;
- this.tipo = t;
- }
- public Subscriptor(Conexion c){
- this.conn = c;
- }
- public boolean setSubscriptor(Subscriptor a) {
- int i;
- String n;
- String t;
- i = a.id;
- n = a.nombre;
- t = a.tipo;
- try {
- String s = "UPDATE subscriptor SET id = " + i + ", nombre = " + n + ", tipo = " + t + " WHERE id = " + i;
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) {System.out.println ("Cannot update Subscriptor" + e); return false;}
- return true;
- }
- public Subscriptor getSubscriptor(int id){
- try {
- conn.stmt.executeQuery ("SELECT id, nombre, tipo FROM subscriptor WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- int i = rs.getInt ("id");
- String n = rs.getString("nombre");
- String t = rs.getString("tipo");
- rs.close();
- Subscriptor resultado = new Subscriptor(i, n, t);
- return( resultado );
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean agregar(int i, String n, String t){
- try {
- String s = "INSERT INTO subscriptor (id, nombre, tipo)" +
- " VALUES ("+ i + " , '" + n + "', " + t + " )";
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot update Subscriptor" + e ); return false;}
- return true;
- }
- public boolean deleteSubscriptor(int id){
- try {
- String s = "DELETE FROM subscriptor WHERE id = " + id;
- System.out.println(s);
- conn.stmt.executeUpdate(s);
- }catch (SQLException e) { System.out.println ("Cannot delete Subscriptor" + e ); return false;}
- return true;
- }
- }
- package entidades;
- import java.sql.*;
- import java.io.*;
- public class SubscriptorPub {
- public int idSub,idPub,costoAdicional;
- public Date fechaEnvio;
- private transient Conexion conn;
- public SubscriptorPub(Conexion c){
- this.conn = c;
- }
- public SubscriptorPub(int idSub, int idPub, int costoAdicional, Date fechaEnvio) {
- this.idSub = idSub;
- this.idPub = idPub;
- this.costoAdicional = costoAdicional;
- this.fechaEnvio = fechaEnvio;
- }
- public SubscriptorPub getSubscriptorPub(int id) {
- try {
- conn.stmt.executeQuery ("SELECT * FROM subscriptorPub WHERE idSub = " + idSub + " and idPub = " + idPub);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.idSub = rs.getInt ("idSub");
- this.idPub = rs.getInt ("idPub");
- this.costoAdicional = rs.getInt ("costoAdicional");
- this.fechaEnvio = rs.getDate ("fechaEnvio");
- rs.close();
- return this;
- }else{ return null;}
- } catch(SQLException e){
- System.out.println(e); return null;
- }
- }
- public boolean setSubscriptorPub(SubscriptorPub j) {
- try{
- conn.stmt.executeUpdate ("UPDATE subscriptorPub SET costoAdicional = " + j.costoAdicional + ", fechaEnvio = " + j.fechaEnvio + " WHERE idSub = " + j.idSub + " and idPub = " + j.idPub);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean insertSubscriptorPub(SubscriptorPub j) {
- try{
- conn.stmt.executeUpdate ("INSERT INTO subscriptorPub (idSub,idPub,costoAdicional,fechaEnvio) VALUES (" + j.idSub + "," + j.idPub + "," + j.costoAdicional + "," + j.fechaEnvio + ")");
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- public boolean deleteSubscriptorPub(int idSub, int idPub) {
- try{
- conn.stmt.executeUpdate ("DELETE FROM puestoRevistasPub WHERE idSub = " + idSub + " and idPub = " + idPub);
- return true;
- } catch(SQLException e) {
- return false;
- }
- }
- }
- package entidades;
- import java.sql.*;
- public class TemaSugerido {
- public int id;
- public int idPub;
- public String tema;
- private transient Conexion conn;
- public TemaSugerido(Conexion co){
- this.conn = co;
- }
- public TemaSugerido(int id, int idPub, String tema){
- this.id = id;
- this.idPub = idPub;
- this.tema = tema;
- }
- public TemaSugerido getTemaSugerido(int id){
- try {
- conn.stmt.executeQuery ("SELECT * FROM temaSugerido WHERE id = " + id);
- ResultSet rs = conn.stmt.getResultSet();
- if (rs.next()) { //Va al primer registro si lo hay
- this.id = rs.getInt("id");
- this.idPub = rs.getInt("idPub");
- this.tema = rs.getString("tema");
- rs.close();
- return(this);
- }else{ return null;}
- } catch (SQLException e) {System.out.println("Excepcion en validar " + e);}
- return null;
- }
- public boolean setTemaSugerido(TemaSugerido tema){
- try {
- String s = "UPDATE temaSugerido SET idPub = " + tema.idPub + ", SET tema = " + tema.tema + " WHERE id = " + tema.id;
- conn.stmt.executeUpdate(s);
- } catch (SQLException e) {System.out.println ("Cannot execute disposicion()" + e);
- return false;
- }
- return true;
- }
- public boolean addTemaSugerido(TemaSugerido tema){
- try {
- conn.stmt.executeUpdate ("INSERT INTO temaSugerido(idPub, tema) VALUES('"+tema.idPub+"','"+tema.tema+"')");
- } catch (SQLException e) {System.out.println ("Cannot getTemaSugerido()" + e);
- return false;
- }
- return true;
- }
- public boolean deleteTemaSugerido(TemaSugerido tema){
- try {
- conn.stmt.executeUpdate ("delete from temaSugerido where id = "+tema.id);
- } catch (SQLException e) {System.out.println ("Cannot setTemaSugerido()" + e);
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment