Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/10/2013, 21:54
neptuno_216
 
Fecha de Ingreso: julio-2011
Mensajes: 39
Antigüedad: 12 años, 9 meses
Puntos: 0
Actualizar e Insertar Campos en SQL

Estimados tengo este problema, no puedo introducir los campos en sql.

Lo que tengo que hacer es insertar y actualizar en la base de datos, para que me vaya actualizando una tabla que está creada la cual no me da problemas.

El campo WorkStation debería ir el nombre del equipo.
En BusinessDate la fecha.
En Status el estado que tendría que ser Open o Close.

Al insertar debería insertar los datos que mencione mas arriba y al actualizar, ir actualizando ( valga la rebundancia) la tabla.

La tabla es la siguiente:

Nombre Tabla: Branch
Campos: WorkStation, BusinessDate, Status


En java tengo esto:

Código Java:
Ver original
  1. public class ControlDAOImpl extends DataBaseConnector implements ControlDAO {
  2.  
  3.       private static final Logger log = Logger.getLogger(ControlDAOImpl.class);
  4.  
  5. private static final String SQL_INSERT_BD = "INSERT INTO BRANCH VALUES(?,?,?)";
  6. private static final String SQL_UPDATE_BD = "UPDATE BRANCH SET WORKSTATION = [[valor1], BUSINESSDATE 2 = [valor2], STATUS 3 = [valor3] WHERE ";
  7.  
  8.  
  9.  
  10.  public void ActualizaBDBranch (String WorkStation, String BusinessDate, String Status) throws DataException {
  11.            
  12.             PreparedStatement st = null;
  13.             ResultSet rs = null;
  14.            
  15.             try{
  16.                   st = super.getConnection().prepareStatement(SQL_UPDATE_BD);
  17.                   st.setString(1, WorkStation);
  18.                   st.setString(2, BusinessDate);
  19.                   st.setString(3, Status);
  20.                  
  21.                   st.executeUpdate();
  22.             } catch (SQLException e) {
  23.                   log.info(e);
  24.                   throw new DataException(e);
  25.             } finally {
  26.                   super.closeResulset(rs);
  27.                   super.closePrepareStament(st);
  28.             }
  29.       }
  30.      
  31.      
  32.       public void InsertarBDBranch (String WorkStation, String BusinessDate, String Status) throws DataException{
  33.            
  34.             PreparedStatement st = null;
  35.             ResultSet rs = null;
  36.            
  37.             try{
  38.                  
  39.                   st = super.getConnection().prepareStatement(SQL_INSERT_BD);
  40.                   //st.setString(1, WorkStation System.getenv("COMPUTERNAME"));
  41.                   st.setString(2, BusinessDate);
  42.                   st.setString(3, Status);
  43.                   st.setString(4, Constantes.EVENT_TYPE_START_BUSINESS_DAY);
  44.                   st.setString(5, Constantes.EVENT_TYPE_END_BUSINESS_DAY);
  45.                  
  46.                   st.executeUpdate();
  47.            
  48.             } catch (SQLException e) {
  49.                   log.info(e);
  50.                   throw new DataException(e);
  51.             } finally {
  52.                   super.closeResulset(rs);
  53.                   super.closePrepareStament(st);
  54.             }
  55.       }



M e podrían ayudar si no es mucha la molestia.
Saludos Cordiales