コード例 #1
0
 @Override
 public void modificar(Object dato) throws SQLException {
   Conexion oCon = new Conexion();
   oCon.getConexion();
   Pelicula aux = (Pelicula) dato;
   String update =
       "UPDATE peliculas SET  Nombre = '"
           + aux.getNombre()
           + "', Director = '"
           + aux.getDirector()
           + "', DuracionPeli = "
           + aux.getDuracion()
           + ",Descripcion = '"
           + aux.getDescripcion()
           + "', Estado = "
           + aux.isEstado()
           + ", UrlImagen = '"
           + aux.getUrlImagen()
           + "' WHERE idPelicula = "
           + aux.getIdPelicula();
   try {
     PreparedStatement sentencia = (PreparedStatement) oCon.getConexion().prepareStatement(update);
     sentencia.execute();
     sentencia.close();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     oCon.close();
   }
 }
コード例 #2
0
  public ArrayList listadoAdmin() throws SQLException {

    Pelicula resp = null;
    Conexion oCon = new Conexion();
    ResultSet rs = null;
    ArrayList listaPeliculas = new ArrayList();
    oCon.getConexion();
    String consulta = "SELECT * FROM peliculas";
    try {
      PreparedStatement sentencia =
          (PreparedStatement) oCon.getConexion().prepareStatement(consulta);
      rs = sentencia.executeQuery();
      while (rs.next()) {
        resp =
            new Pelicula(
                rs.getInt("idPelicula"),
                rs.getString("Nombre"),
                rs.getString("Director"),
                rs.getInt("DuracionPeli"),
                rs.getString("Descripcion"),
                rs.getBoolean("Estado"),
                rs.getString("UrlImagen"));
        listaPeliculas.add(resp);
      }
      rs.close();
      sentencia.close();
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      oCon.close();
      return listaPeliculas;
    }
  }
コード例 #3
0
 @Override
 public Object existe(Object dato) throws SQLException {
   Pelicula resp = null;
   Conexion oCon = new Conexion();
   ResultSet rs = null;
   oCon.getConexion();
   String consulta = "SELECT * FROM peliculas where idPelicula =" + ((int) dato);
   try {
     PreparedStatement sentencia =
         (PreparedStatement) oCon.getConexion().prepareStatement(consulta);
     rs = sentencia.executeQuery();
     while (rs.next()) {
       resp =
           new Pelicula(
               rs.getInt("idPelicula"),
               rs.getString("Nombre"),
               rs.getString("Director"),
               rs.getInt("DuracionPeli"),
               rs.getString("Descripcion"),
               rs.getBoolean("Estado"),
               rs.getString("UrlImagen"));
     }
     rs.close();
     sentencia.close();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     oCon.close();
     return resp;
   }
 }
コード例 #4
0
 @Override
 public void baja(Object dato) throws SQLException {
   Conexion oCon = new Conexion();
   oCon.getConexion();
   String consulta = "UPDATE peliculas set Estado = false where idPelicula =" + ((int) dato);
   try {
     PreparedStatement sentencia =
         (PreparedStatement) oCon.getConexion().prepareStatement(consulta);
     sentencia.execute();
     sentencia.close();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     oCon.close();
   }
 }
コード例 #5
0
 @Override
 public void alta(Object dato) throws SQLException {
   Conexion oCon = new Conexion();
   oCon.getConexion();
   Pelicula aux = (Pelicula) dato;
   String insert =
       "INSERT INTO peliculas(nombre, director, duracionPeli, descripcion, estado,UrlImagen) VALUES(?,?,?,?,?,?)";
   try {
     PreparedStatement sentencia = (PreparedStatement) oCon.getConexion().prepareStatement(insert);
     sentencia.setString(1, aux.getNombre());
     sentencia.setString(2, aux.getDirector());
     sentencia.setInt(3, aux.getDuracion());
     sentencia.setString(4, aux.getDescripcion());
     sentencia.setBoolean(5, aux.isEstado());
     sentencia.setString(6, aux.getUrlImagen());
     sentencia.execute();
     sentencia.close();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     oCon.close();
   }
 }