2011-05-25 4 views
1

J'ai le code suivant:problème étrange exception en Java et Oracle

package model.composite; 

import java.util.Date; 
import Nwt.Registro; 
import java.sql.ResultSet; 

import annotations.DateFormatAnnotation; 

/** 
* Clase que declara el tipo de registro para manejar la información del turno de servicio. 
* @author xx357 
* 
*/ 
public class RegistroTur extends Registro{ 
    private String codrec; 
    private String locrec; 
    private String turdsr; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date fecrec; 
    private String estrec; 
    private String estemi; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date fecemi; 
    private String estcre; 
    private int  priwls; 
    private String delope; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date fecope; 
    private String nomage; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date faxpet; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date Faxcnx; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date Faxprs; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date Faxcnp; 
    private String usrcre; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date datcre; 
    private String usrmod; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date datmod; 
    @DateFormatAnnotation(patron = "dd/MM/yyyy HH:mm") 
    private Date fecbaj; 
    private String usrbaj; 
    private String tarext; 
    private String codaut; 
    private String carmat; 

    public RegistroTur(){ 
    } 

    public RegistroTur(ResultSet rs) throws Exception{ 
     setCodrec(rs.getString(1)); 
     setLocrec(rs.getString(2)); 
     setTurdsr(rs.getString(3)); 
     setFecrec(rs.getTimestamp(4)); 
     setEstrec(rs.getString(5)); 

     setEstemi(rs.getString(6)); 
     setFecemi(rs.getTimestamp(7)); 
     setEstcre(rs.getString(8)); 
     setPriwls(rs.getInt(9)); 
     setDelope(rs.getString(10)); 

     setFecope(rs.getTimestamp(11)); 
     setNomage(rs.getString(12)); 
     setFaxpet(rs.getTimestamp(13)); 
     setFaxcnx(rs.getTimestamp(14)); 
     setFaxprs(rs.getTimestamp(15)); 

     setFaxcnp(rs.getTimestamp(16)); 
     setUsrcre(rs.getString(17)); 
     setDatcre(rs.getTimestamp(18)); 
     setUsrmod(rs.getString(19)); 
     setDatmod(rs.getTimestamp(20)); 

     setFecbaj(rs.getTimestamp(21)); 
     setUsrbaj(rs.getString(22)); 
     setTarext(rs.getString(23)); 
     setCodaut(rs.getString(24)); 
     setCarmat(rs.getString(25)); 
    } 

    public void setCodrec(String codrec) { 
     this.codrec = codrec; 
    } 

    public String getCodrec() { 
     return codrec; 
    } 

    public void setLocrec(String locrec) { 
     this.locrec = locrec; 
    } 

    public String getLocrec() { 
     return locrec; 
    } 

    public void setTurdsr(String turdsr) { 
     this.turdsr = turdsr; 
    } 

    public String getTurdsr() { 
     return turdsr; 
    } 

    public void setFecrec(Date fecrec) { 
     this.fecrec = fecrec; 
    } 

    public Date getFecrec() { 
     return fecrec; 
    } 

    public void setEstrec(String estrec) { 
     this.estrec = estrec; 
    } 

    public String getEstrec() { 
     return estrec; 
    } 

    public void setEstemi(String estemi) { 
     this.estemi = estemi; 
    } 

    public String getEstemi() { 
     return estemi; 
    } 

    public void setFecemi(Date fecemi) { 
     this.fecemi = fecemi; 
    } 

    public Date getFecemi() { 
     return fecemi; 
    } 

    public void setEstcre(String estcre) { 
     this.estcre = estcre; 
    } 

    public String getEstcre() { 
     return estcre; 
    } 

    public void setPriwls(int priwls) { 
     this.priwls = priwls; 
    } 

    public int getPriwls() { 
     return priwls; 
    } 

    public void setDelope(String delope) { 
     this.delope = delope; 
    } 

    public String getDelope() { 
     return delope; 
    } 

    public void setFecope(Date fecope) { 
     this.fecope = fecope; 
    } 

    public Date getFecope() { 
     return fecope; 
    } 

    public void setNomage(String nomage) { 
     this.nomage = nomage; 
    } 

    public String getNomage() { 
     return nomage; 
    } 

    public void setFaxpet(Date faxpet) { 
     this.faxpet = faxpet; 
    } 

    public Date getFaxpet() { 
     return faxpet; 
    } 

    public void setFaxcnx(Date faxcnx) { 
     Faxcnx = faxcnx; 
    } 

    public Date getFaxcnx() { 
     return Faxcnx; 
    } 

    public void setFaxprs(Date faxprs) { 
     Faxprs = faxprs; 
    } 

    public Date getFaxprs() { 
     return Faxprs; 
    } 

    public void setFaxcnp(Date faxcnp) { 
     Faxcnp = faxcnp; 
    } 

    public Date getFaxcnp() { 
     return Faxcnp; 
    } 

    public void setUsrcre(String usrcre) { 
     this.usrcre = usrcre; 
    } 

    public String getUsrcre() { 
     return usrcre; 
    } 

    public void setDatcre(Date datcre) { 
     this.datcre = datcre; 
    } 

    public Date getDatcre() { 
     return datcre; 
    } 

    public void setUsrmod(String usrmod) { 
     this.usrmod = usrmod; 
    } 

    public String getUsrmod() { 
     return usrmod; 
    } 

    public void setDatmod(Date datmod) { 
     this.datmod = datmod; 
    } 

    public Date getDatmod() { 
     return datmod; 
    } 

    public void setFecbaj(Date fecbaj) { 
     this.fecbaj = fecbaj; 
    } 

    public Date getFecbaj() { 
     return fecbaj; 
    } 

    public void setUsrbaj(String usrbaj) { 
     this.usrbaj = usrbaj; 
    } 

    public String getUsrbaj() { 
     return usrbaj; 
    } 

    public void setTarext(String tarext) { 
     this.tarext = tarext; 
    } 

    public String getTarext() { 
     return tarext; 
    } 

    public void setCodaut(String codaut) { 
     this.codaut = codaut; 
    } 

    public String getCodaut() { 
     return codaut; 
    } 

    public void setCarmat(String carmat) { 
     this.carmat = carmat; 
    } 

    public String getCarmat() { 
     return carmat; 
    } 
} 

Lorsque j'exécute la ligne avec setFecrec (rs.getTimestamp (4)); il jette l'exception: java.lang.ArrayIndexOutOfBoundsException: -1

Je ne sais pas quoi faire. Le champ dans la base de données est vide et le champ est DATE dans la base de données.

+1

Veuillez fournir une trace de pile complète ('e.printStackTrace()' l'imprimera). Dites-nous également quelle version du pilote oracle jdbc vous utilisez et la version de la base de données. – dogbane

Répondre

2

L'erreur nous indique que l'ensemble de résultats actuel, transmis aux constructeurs, reflète une table avec seulement trois colonnes. Si l'entrée à l'index 4 n'était pas correctement formatée, un type d'exception différent s'afficherait.

Je regarderais l'instruction réelle qui produit ce résultat.

0

Le problème était une différence de formats db pour les champs DATE. C'est déjà réparé. Merci à tous de toute façon.

Questions connexes