Click to See Complete Forum and Search --> : problem with data field


eu.rafael
09-26-2004, 04:10 PM
Hello!
Iīm developping an application with MySQL db. When I try to get a data field with resultset.getDate("field"), the date itīs null (when it shouldnīt be). If i use resultset.getString("field"), the date itīs 0000-00-00. Whatīs thr problem? What should i do?
Thankīs for your attention.

ray326
09-26-2004, 08:19 PM
How do you know it shouldn't be null? Have you issued the same query from some other tool (like the mysql command line interface) and seen the date was there?

Khalid Ali
09-27-2004, 01:04 AM
I bet date is null and is not parseable by getDate() object to convert it to sql.date....

eu.rafael
09-27-2004, 05:53 AM
Well, i donīt now why but the date in the first try, really shouldnīt be null (iīve checked on mysql prompt, i swear).... but itīs working now (i didnīt find any mistake).... take a look on the source code

this.resultset = this.statement.executeQuery("Select * from solicitacao_servico where cod_solicitacao="+Integer.parseInt(codigo)+"");
this.resultset.next();
this.codsol = this.resultset.getString("cod_solicitacao");
this.horacriacao = this.resultset.getString("hor_abertura");
this.d = this.resultset.getDate("dat_abertura");
this.priocc = this.resultset.getString("prioridade_cc");
this.sazon = this.resultset.getString("prioridade_cc_atendimento");
this.origem = this.resultset.getString("origem_solicitacao");
this.tipo = this.resultset.getString("tipo_solicitacao");
this.anexo = this.resultset.getString("anexos");
this.descricao = this.resultset.getString("observacoes");
this.id = this.resultset.getString("cod_equipamento");
this.data = this.d.toString();

Thankīs for your attentions

ray326
09-27-2004, 10:19 AM
If the date is definitely in the database and the object only fails the first time it's used then that usually indicates the object is not being created the way you think it is.