Subject | Exception in setBigDecimal |
---|---|
Author | Leonardo Vieira Cervo |
Post date | 2004-04-27T13:31:10Z |
Hi,
I hava a table:
CREATE TABLE PACIENTE_MEDIDA (
CD_PAC INTEGER NOT NULL,
DT_HR TIMESTAMP NOT NULL,
PESO DOUBLE PRECISION,
ALTURA NUMERIC(8,4)
);
When I try to do a insert with null values:
...
PreparedStatement psInsert = con.prepareStatement("insert into
paciente_medida(peso,altura,dt_hr,cd_pac) values(?,?,?,?)");
psInsert.setBigDecimal(1,null);
psInsert.setBigDecimal(2,null); // <- throws exception
psInsert.setDate(3,new
Date(Calendar.getInstance().getTimeInMillis()));
psInsert.setInt(4,1);
...
It throws a NPE with the stack trace:
java.lang.NullPointerException
at
org.firebirdsql.jdbc.field.FBBigDecimalField.setBigDecimal(FBBigDecimalField.java:203)
at
org.firebirdsql.jdbc.AbstractPreparedStatement.setBigDecimal(AbstractPreparedStatement.java:239)
at
com.dixtal.quati.negocio.dao.PacienteMedidaDAO.update(PacienteMedidaDAO.java:62)
...
Am I doing something wrong? If I change the second setBigDecimal to
setObject it works.
Thanks,
Leonardo.
I hava a table:
CREATE TABLE PACIENTE_MEDIDA (
CD_PAC INTEGER NOT NULL,
DT_HR TIMESTAMP NOT NULL,
PESO DOUBLE PRECISION,
ALTURA NUMERIC(8,4)
);
When I try to do a insert with null values:
...
PreparedStatement psInsert = con.prepareStatement("insert into
paciente_medida(peso,altura,dt_hr,cd_pac) values(?,?,?,?)");
psInsert.setBigDecimal(1,null);
psInsert.setBigDecimal(2,null); // <- throws exception
psInsert.setDate(3,new
Date(Calendar.getInstance().getTimeInMillis()));
psInsert.setInt(4,1);
...
It throws a NPE with the stack trace:
java.lang.NullPointerException
at
org.firebirdsql.jdbc.field.FBBigDecimalField.setBigDecimal(FBBigDecimalField.java:203)
at
org.firebirdsql.jdbc.AbstractPreparedStatement.setBigDecimal(AbstractPreparedStatement.java:239)
at
com.dixtal.quati.negocio.dao.PacienteMedidaDAO.update(PacienteMedidaDAO.java:62)
...
Am I doing something wrong? If I change the second setBigDecimal to
setObject it works.
Thanks,
Leonardo.