Posted Sunday, July 22, 2007 @ 02:49:20
i'm using quicktable with mysql 5 but i have a problem setting double values to db.I have set the column properties as CustemerOrderDemo example :
table1.createColumnModelFromQuery();
c = table1.getColumn(4);
c.setType(java.sql.Types.DOUBLE);
c.setPrecision(10);
c.setScale(2);
c.setMinWidth(40);
c.setMaxWidth(60);
c.setHeaderValue("Prezzo");
c.setReadOnly(false);
c.setSigned(true);
here comes the db structure :
CREATE TABLE `prodotti` (
`id` bigint(20) NOT NULL auto_increment,
`cod` varchar(10) NOT NULL default '',
`nome` varchar(30) NOT NULL,
`prezzo` double default '0',
`magg` double NOT NULL default '0',
`id_tipo` tinyint(4) NOT NULL default '5',
`imballaggio` varchar(1) NOT NULL,
`calopeso` tinyint(1) NOT NULL,
`report` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=83 DEFAULT CHARSET=latin1 AUTO_INCREMENT=83 ;
I tried various settings: setPrecision(22) setScale(31) for example but nothing works. After that i tried the working CustomerOrderDemo with a mysql db
,copied from the quicktable.mdb .The problem happens with mysql db not with mdb.So i think that the problem is related to db structure but i can't figure
out how to fix the db.Can u help me?Thanks
this is an extract from the debug:
Database meta data information received from jdbc driver
Column 4: Name: price
ReadOnly: false
Data Type: DOUBLE
Precision: 22
Scale: 31
Signed: false
Column :4 Warning: Your JDBC driver or your setting, gives the precision of the column data as 5.
Column :4 Warning: If precision 5 is less than scale 31, you won't be able to enter any data into the cell of this column
Column :4 Adjust scale & precision , Using yourQT.getColumn(i).setPrecision(20) or setScale(2)
Hint about Precision/Scale: Lets say, the numeric value is of type 1234.56, then precision is 6 (total number of digits) and scale is 2 (number of digits after the dot).
To hide this message,refer to DBTable.showCriticalWarnings api doc.