开发者

Problem with strange exception in java and oracle

开发者 https://www.devze.com 2023-03-08 03:38 出处:网络
I\'ve got the next code: package model.composite; import java.util.Date; import Nwt.Registro; import java.sql.ResultSet;

I've got the next code:

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;

 开发者_StackOverflow社区   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;
    }
}

When I execute the line with setFecrec(rs.getTimestamp(4)); it throws the exception: java.lang.ArrayIndexOutOfBoundsException: -1

I don't know what to do. The field in the db comes with null, and the field is type DATE in the database.


The error tells us, that the actual result set, that is passed to the constructors reflects a table with only three columns. If the entry at index 4 wasn't properly formatted, then we'd see a different exception type.

I'd look at the actual statement that produces this resultset.


The problem was a difference of db formats for DATE fields. It's already fixed. Thanks all anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消