Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/06/2010, 16:08
syriek
 
Fecha de Ingreso: junio-2010
Mensajes: 1
Antigüedad: 13 años, 10 meses
Puntos: 0
Como Enviar una fecha (STRING) a un registro tipo DATE

Saludos a todos

quisiera que me ayudara a resolver el siguiente problema:

Tengo dodo clase Representante y Representante DAO:

Representante.java
package Objetos;
import java.util.*;
import java.text.SimpleDateFormat;

public class Representante{

int tipoIdent;
int cedula;
String Pnombre;
String Snombre;
String Papellido;
String Sapellido;
Date fechanac;
String licencia;
String dirresidencia;
int pais;
int departamento;
int ciudad;
int telefono;
int celular;
String email;
String nomhotel;
int telhotel;
String dirhotel;



public Representante(int tipoIdent,int cedula,String Pnombre,String Snombre, String Papellido, String Sapellido, Date fechanac, String licencia,String dirresidencia, int pais, int departamneto, int ciudad, int telefono, int celular,String email,String nomhotel, int telhotel, String dirhotel)
{
this.tipoIdent=tipoIdent;
this.cedula=cedula;
this.Pnombre=Pnombre;
this.Snombre=Snombre;
this.Papellido=Papellido;
this.Sapellido=Sapellido;
this.fechanac=fechanac;
this.licencia=licencia;
this.dirresidencia=dirresidencia;
this.pais=pais;
this.departamento=departamento;
this.ciudad=ciudad;
this.telefono=telefono;
this.celular=celular;
this.email=email;
this.nomhotel=nomhotel;
this.telhotel=telhotel;
this.dirhotel=dirhotel;

}
public int getcedula()
{
return cedula;
}

public int gettipoIdent()
{
return tipoIdent;
}

public String getPnombre()
{
return Pnombre;
}

public String getSnombre()
{
return Snombre;
}

public String getPapellido()
{
return Papellido;
}

public String getSapellido()
{
return Sapellido;
}

public Date getfechanac()
{
return fechanac;
}

public String getlicencia()
{
return licencia;
}
public String getdirresidencia()
{
return dirresidencia;
}

public int getpais()
{
return pais;
}

public int getdepartamento()
{
return departamento;
}

public int getciudad()
{
return ciudad;
}

public int gettelefono()
{
return telefono;
}

public int getcelular()
{
return celular;
}

public String getemail()
{
return email;
}


public String getnomhotel()
{
return nomhotel;
}
public String getdirhotel()
{
return dirhotel;
}

public int gettelhotel()
{
return telhotel;
}



}

RepresentanteDAO.java


package Objetos;
import java.sql.*;

import java.util.ArrayList;
import java.util.List;
;
import java.util.Date;



public class RepresentanteDAO{


public int GuardarRepre(Representante re)
{
int fila=0;

try
{

//Cargar el controlador
Class.forName("com.mysql.jdbc.Driver");
//crear una coneccion con la DB
Connection conexion=DriverManager.getConnection("jdbc:mysql://localhost/db","root","1234");
//crear objeto para realizar consultas,inseciones, borrados, etc
PreparedStatement instruccion = conexion.prepareStatement("insert into representante_legal values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
instruccion.setInt(1,re.gettipoIdent());
instruccion.setInt(2,re.getcedula());
instruccion.setString(3,re.getPnombre());
instruccion.setString(4,re.getSnombre());
instruccion.setString(5,re.getPapellido());
instruccion.setString(6,re.getSapellido());
instruccion.setDate(7,re.getfechanac());
instruccion.setString(8,re.getlicencia());
instruccion.setString(9,re.getdirresidencia());
instruccion.setInt(10,re.getpais());
instruccion.setInt(11,re.getdepartamento());
instruccion.setInt(12,re.getciudad());
instruccion.setInt(13,re.gettelefono());
instruccion.setInt(14,re.getcelular());
instruccion.setString(15,re.getemail());
instruccion.setString(16,re.getnomhotel());
instruccion.setInt(17,re.gettelhotel());
instruccion.setString(18,re.getdirhotel());




///Ejecuto la instruccion
fila=instruccion.executeUpdate();

}catch(Exception e)
{
System.out.println("Error:"+e);
}
//retorno el numero de filas que guardo
return fila;

}

/*public int EliminarPais(int id)
{
int fila=0;

try
{

//Cargar el controlador
Class.forName("com.mysql.jdbc.Driver");
//crear una coneccion con la DB
Connection conexion=DriverManager.getConnection("jdbc:mysql://localhost/db","root","1234");
//crear objeto para realizar consultas,inseciones, borrados, etc
PreparedStatement instruccion = conexion.prepareStatement("delete from pais where id=?");
instruccion.setInt(1,id);
///Ejecuto la instruccion
fila=instruccion.executeUpdate();

}catch(Exception e)
{
System.out.println("Error:"+e);
}
//retorno el numero de filas que guardo
return fila;

}*/

/*public List getRepr()
{
int fila=0;
ArrayList<Representante> repre=null;

try
{

//Cargar el controlador
Class.forName("com.mysql.jdbc.Driver");
//crear una coneccion con la DB
Connection conexion=DriverManager.getConnection("jdbc:mysql://localhost/db","root","1234");
//crear objeto para realizar consultas,inseciones, borrados, etc
PreparedStatement instruccion = conexion.prepareStatement("select * from representante_legal");
///Ejecuto la instruccion
ResultSet r=instruccion.executeQuery();

repre= new ArrayList<Representante> ();

while(r.next())
{

Representante rp=new Representante(Integer.parseInt(r.getString(1)), Integer.parseInt(r.getString(2)),r.getString(3),r. getString(4), r.getString(5), r.getString(6), r.getString(7), r.getString(8), r.getString(9),Integer.parseInt(r.getString(10)),I nteger.parseInt(r.getString(11)),Integer.parseInt( r.getString(12)),Integer.parseInt(r.getString(13)) ,Integer.parseInt(r.getString(14)),r.getString(15) ,r.getString(16),Integer.parseInt(r.getString(17)) ,r.getString(18));
repre.add(rp);

}


}catch(Exception e)
{
System.out.println("Error: "+e);
}
//retorno el numero de filas que guardo
return repre;

} */

public static void main (String arg []) {
try{

RepresentanteDAO red= new RepresentanteDAO();
//Representante re=Representante(85,1082,"antonio","jose","brtio", "jimenez",'10'+'01'+'1990',"78899-ab","calle 13",1,1,1,4206987,3014578,"[email protected]","tama ca",4782586,"km 48 via gaira");
//red.GuardarRepre(re);

}

catch (Exception e)
{

System.out.println ("Error en el main: "+e);
}


}


}

Cuado Compilo esta ultima clase me genera el siguiente error:

cannot find symbol method setDate(int,java.util.Date)

este error marca la siguiente instruccion: instruccion.setDate(7,re.getfechanac());


Por favor alguien me puede decir como soluciono este inconveniente!!!!


De ante mano les agradezco su atencion!!!!

Última edición por syriek; 25/06/2010 a las 07:24