public boolean save() throws ClassNotFoundException, SQLException { Connection con = Conexion.abrirConexion(); ConsultaSegura.hacerConsulta( con, "insert into " + tabladb + " values(?,?,?,?,?,?,?)", this.toArray()); Conexion.cerrarConexion(con); return true; }
public boolean save() throws ClassNotFoundException, SQLException { Connection con = Conexion.abrirConexion(); ConsultaSegura.hacerConsulta( con, "insert into " + tabladb + " (titulo,mensaje,tiene_imagen,nombre_usuario,fecha_evento,hora_inicio,hora_fin) values(?,?,?,?,?,?,?)", this.toArray()); Conexion.cerrarConexion(con); return true; }
public static boolean delete(String using, String where, ArrayList<String> datos) throws ClassNotFoundException { Connection con = Conexion.abrirConexion(); if (con != null) { ConsultaSegura.hacerConsulta( con, "delete from " + tabladb + " " + using + " where " + where, datos); Conexion.cerrarConexion(con); return true; } else { return false; } }
public static ArrayList<Evento> get(String select, String complex, ArrayList<String> datos) throws ClassNotFoundException, NumberFormatException, SQLException { Connection con = Conexion.abrirConexion(); ArrayList<Evento> reg = new ArrayList<Evento>(); if (con != null) { ResultSet res = ConsultaSegura.hacerConsulta( con, "select " + select + " from " + tabladb + " " + (complex.equals("") ? " " : complex), datos); while (res.next()) { Evento r = new Evento(); try { r.setTitulo(res.getString("titulo")); } catch (SQLException e) { } try { r.setMensaje(res.getString("mensaje")); } catch (SQLException e) { } try { r.setTieneImagen(res.getBoolean("tiene_imagen")); } catch (SQLException e) { } try { r.setNombreUsuario(res.getString("nombre_usuario")); } catch (SQLException e) { } try { r.setFechaEvento(res.getDate("fecha_evento")); } catch (SQLException e) { } try { r.setHoraInicio(res.getTime("hora_inicio")); } catch (SQLException e) { } try { r.setHoraFin(res.getTime("hora_fin")); } catch (SQLException e) { } r.setId(res.getInt("id")); reg.add(r); } Conexion.cerrarConexion(con); return reg; } else { return null; } }
public static ArrayList<Registrado> get(String select, String complex, ArrayList<String> datos) throws ClassNotFoundException, NumberFormatException, SQLException { Connection con = Conexion.abrirConexion(); ArrayList<Registrado> reg = new ArrayList<Registrado>(); if (con != null) { ResultSet res = ConsultaSegura.hacerConsulta( con, "select " + select + " from " + tabladb + " " + (complex.equals("") ? "" : complex), datos); while (res.next()) { Registrado r = new Registrado(); try { r.setNombreUsuario(res.getString("nombre_usuario")); } catch (SQLException e) { } try { r.setNombre(res.getString("nombre")); } catch (SQLException e) { } try { r.setApellido(res.getString("apellido")); } catch (SQLException e) { } try { r.setEdad(Integer.parseInt(res.getString("edad"))); } catch (SQLException e) { } try { r.setCorreo(res.getString("correo")); } catch (SQLException e) { } try { r.setClave(res.getString("clave")); } catch (SQLException e) { } try { r.setImagenPerfil(res.getString("imagen_perfil")); } catch (SQLException e) { } reg.add(r); } Conexion.cerrarConexion(con); return reg; } else { return null; } }