Subject | jaybird returns zero instead of null for DECIMAL colmn |
---|---|
Author | paulstevenhowells |
Post date | 2008-06-17T23:54:08Z |
Hopefully someone out there can point me int he right direction.
I have a Firebird 2.1 database installed on Windows XP. I am
accessing the DB from a java web application using the jaybird-full-
2.1.3.jar JDBC driver. My problem is that when I select null from my
"primary_image decimal(10)" column the result set returns zero. I
need it to return null. I don't know if this is a feature that I
need to turn off or what. The table definition and log4j logs are
below...
create table inventory_item (
inventory_item_id decimal(10) primary key,
name varchar(254) not null,
short_description varchar(2000) not null,
long_description BLOB SUB_TYPE TEXT,
price decimal(18,2) not null,
primary_image decimal(10),
deleted_ind varchar(1) not null,
entry_userid varchar(100) not null,
entry_timestamp timestamp not null,
update_userid varchar(100) not null,
update_timestamp timestamp not null,
FOREIGN KEY (primary_image) REFERENCES image (image_id)
);
DEBUG java.sql.PreparedStatement - {pstm-100055} Executing
Statement:
INSERT INTO INVENTORY_ITEM (
INVENTORY_ITEM_ID,
NAME,
SHORT_DESCRIPTION,
LONG_DESCRIPTION,
PRICE,
PRIMARY_IMAGE,
DELETED_IND,
ENTRY_USERID,
ENTRY_TIMESTAMP,
UPDATE_USERID,
UPDATE_TIMESTAMP
) VALUES (
?,
?,
?,
?,
?,
?,
'N',
?,
CURRENT_TIMESTAMP,
?,
CURRENT_TIMESTAMP
);
DEBUG java.sql.PreparedStatement - {pstm-100055} Parameters: [1,
item1, SD, Ld, 7.0, null, nhowells, nhowells]
DEBUG java.sql.PreparedStatement - {pstm-100055} Types:
[java.lang.Long, java.lang.String, java.lang.String,
java.lang.String, java.lang.Double, null, java.lang.String,
java.lang.String]
DEBUG java.sql.Connection - {conn-100056} Preparing Statement:
SELECT T.INVENTORY_ITEM_ID,
T.NAME,
T.SHORT_DESCRIPTION,
T.LONG_DESCRIPTION,
T.PRICE,
T.PRIMARY_IMAGE,
T.ENTRY_USERID,
T.ENTRY_TIMESTAMP,
T.UPDATE_USERID,
T.UPDATE_TIMESTAMP
FROM INVENTORY_ITEM T
WHERE T.DELETED_IND = 'N'
AND T.INVENTORY_ITEM_ID = ?;
DEBUG java.sql.PreparedStatement - {pstm-100057} Executing
Statement:
SELECT T.INVENTORY_ITEM_ID,
T.NAME,
T.SHORT_DESCRIPTION,
T.LONG_DESCRIPTION,
T.PRICE,
T.PRIMARY_IMAGE,
T.ENTRY_USERID,
T.ENTRY_TIMESTAMP,
T.UPDATE_USERID,
T.UPDATE_TIMESTAMP
FROM INVENTORY_ITEM T
WHERE T.DELETED_IND = 'N'
AND T.INVENTORY_ITEM_ID = ?;
DEBUG java.sql.PreparedStatement - {pstm-100057} Parameters: [1]
DEBUG java.sql.PreparedStatement - {pstm-100057} Types:
[java.lang.Long]
DEBUG java.sql.ResultSet - {rset-100058} ResultSet
DEBUG java.sql.ResultSet - {rset-100058} Header: [INVENTORY_ITEM_ID,
NAME, SHORT_DESCRIPTION, LONG_DESCRIPTION, PRICE, PRIMARY_IMAGE]
DEBUG java.sql.ResultSet - {rset-100058} Result: [1, item1, SD, Ld,
7.0, 0]
You can see above that a null is being inserted into in the
PRIMARY_IMAGE column. I have verified that it is null in the
database by using another tool. When the above SQL is executed the
null is returned as zero. WFT?
Any help appreciated.
Thanks
Paul
I have a Firebird 2.1 database installed on Windows XP. I am
accessing the DB from a java web application using the jaybird-full-
2.1.3.jar JDBC driver. My problem is that when I select null from my
"primary_image decimal(10)" column the result set returns zero. I
need it to return null. I don't know if this is a feature that I
need to turn off or what. The table definition and log4j logs are
below...
create table inventory_item (
inventory_item_id decimal(10) primary key,
name varchar(254) not null,
short_description varchar(2000) not null,
long_description BLOB SUB_TYPE TEXT,
price decimal(18,2) not null,
primary_image decimal(10),
deleted_ind varchar(1) not null,
entry_userid varchar(100) not null,
entry_timestamp timestamp not null,
update_userid varchar(100) not null,
update_timestamp timestamp not null,
FOREIGN KEY (primary_image) REFERENCES image (image_id)
);
DEBUG java.sql.PreparedStatement - {pstm-100055} Executing
Statement:
INSERT INTO INVENTORY_ITEM (
INVENTORY_ITEM_ID,
NAME,
SHORT_DESCRIPTION,
LONG_DESCRIPTION,
PRICE,
PRIMARY_IMAGE,
DELETED_IND,
ENTRY_USERID,
ENTRY_TIMESTAMP,
UPDATE_USERID,
UPDATE_TIMESTAMP
) VALUES (
?,
?,
?,
?,
?,
?,
'N',
?,
CURRENT_TIMESTAMP,
?,
CURRENT_TIMESTAMP
);
DEBUG java.sql.PreparedStatement - {pstm-100055} Parameters: [1,
item1, SD, Ld, 7.0, null, nhowells, nhowells]
DEBUG java.sql.PreparedStatement - {pstm-100055} Types:
[java.lang.Long, java.lang.String, java.lang.String,
java.lang.String, java.lang.Double, null, java.lang.String,
java.lang.String]
DEBUG java.sql.Connection - {conn-100056} Preparing Statement:
SELECT T.INVENTORY_ITEM_ID,
T.NAME,
T.SHORT_DESCRIPTION,
T.LONG_DESCRIPTION,
T.PRICE,
T.PRIMARY_IMAGE,
T.ENTRY_USERID,
T.ENTRY_TIMESTAMP,
T.UPDATE_USERID,
T.UPDATE_TIMESTAMP
FROM INVENTORY_ITEM T
WHERE T.DELETED_IND = 'N'
AND T.INVENTORY_ITEM_ID = ?;
DEBUG java.sql.PreparedStatement - {pstm-100057} Executing
Statement:
SELECT T.INVENTORY_ITEM_ID,
T.NAME,
T.SHORT_DESCRIPTION,
T.LONG_DESCRIPTION,
T.PRICE,
T.PRIMARY_IMAGE,
T.ENTRY_USERID,
T.ENTRY_TIMESTAMP,
T.UPDATE_USERID,
T.UPDATE_TIMESTAMP
FROM INVENTORY_ITEM T
WHERE T.DELETED_IND = 'N'
AND T.INVENTORY_ITEM_ID = ?;
DEBUG java.sql.PreparedStatement - {pstm-100057} Parameters: [1]
DEBUG java.sql.PreparedStatement - {pstm-100057} Types:
[java.lang.Long]
DEBUG java.sql.ResultSet - {rset-100058} ResultSet
DEBUG java.sql.ResultSet - {rset-100058} Header: [INVENTORY_ITEM_ID,
NAME, SHORT_DESCRIPTION, LONG_DESCRIPTION, PRICE, PRIMARY_IMAGE]
DEBUG java.sql.ResultSet - {rset-100058} Result: [1, item1, SD, Ld,
7.0, 0]
You can see above that a null is being inserted into in the
PRIMARY_IMAGE column. I have verified that it is null in the
database by using another tool. When the above SQL is executed the
null is returned as zero. WFT?
Any help appreciated.
Thanks
Paul