Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/12/2012, 13:51
yamidvo
 
Fecha de Ingreso: junio-2012
Ubicación: colombia
Mensajes: 48
Antigüedad: 11 años, 11 meses
Puntos: 0
Exclamación Problema con fecha en java mysql y JDateChooser

Hola compañeros
tengo un problema con un complemento que le agregue a netbeans.

en la base de datos tengo un campo tipo date y cree un objeto tipo date en el codigo java. pero me aparece un error en el PreparedStatement.
este es el codigo:
Código java:
Ver original
  1. String ref, nom;
  2.         String preUnit, total, cant;
  3.         Date f=new Date();//creacion objeto date
  4.         String Ssql="";
  5.         String mensaje="";
  6.         ref=txtReferencia.getText();
  7.         nom=NomProducto.getText();
  8.         preUnit=PrecioUnit.getText();
  9.         cant=cantidad.getText();
  10.         total=Total.getText();
  11.         f=fecha.getDate(); //Aqui se instancia el objeto
  12.        
  13.         int PrecioUnitario,Cant,Tot;
  14.         PrecioUnitario=Integer.parseInt(preUnit);
  15.         Cant=Integer.parseInt(cant);
  16.         Tot=Integer.parseInt(total);
  17.        
  18.         Ssql = "INSERT INTO ingresar_producto(Referencia, Nombre, Precio_unit, Cantidad, Total, Fecha_ingreso)" +
  19.                 "VALUES(?, ?, ?, ?, ?, ?)";
  20.         mensaje = "Los datos se han Insertado de Manera Satisfactoria...";
  21.        
  22.          try
  23.         {
  24.             PreparedStatement pst = cn.prepareStatement(Ssql);
  25.             pst.setString(1, ref);
  26.             pst.setString(2, nom);
  27.             pst.setInt(3, PrecioUnitario);
  28.             pst.setInt(4, Cant);
  29.             pst.setInt(5, Tot);
  30.             pst.setDate(6, f);//ERROR no suitable method found for setdate...
  31.  
  32.             int n = pst.executeUpdate();
  33.  
  34.             if(n > 0)
  35.             {
  36.                 JOptionPane.showMessageDialog(null, mensaje);              
  37.             }
  38.         }
  39.         catch (SQLException ex)
  40.         {
  41.             JOptionPane.showMessageDialog(null, ex);
  42.         }