craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > JDBC/Database Issues Post New Topic   Post A Reply
double value problem with mysql db printer friendly version
next newest post | next oldest post
Author Messages
yeffa
Private

Gender: Male
Location: Itaky
Registered: Jul 2007
Status: Offline
Posts: 5

Click here to see the profile for yeffa Send email to yeffa Find more posts by yeffa Edit or delete this message Reply w/Quote
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.

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Monday, July 23, 2007 @ 13:31:00  

Can you explain a little more about what is the problem? Do you have problems with viewing the data or editing/updating the data? Some of the debug messages might be warnings, you can ignore them.

even if mysql gives incorrect scale & precision, you are setting it right as below. This should fix the problem.

c = table1.getColumn(4);
c.setType(java.sql.Types.DOUBLE);
c.setPrecision(10);
c.setScale(2);

But the above settings will be refreshed when you call again setSelectSql() and call refresh. If needed, use dbTable.useOldColumnProperties(true). refer api for more information.

precision should be always greater than scale. so, Precision=22 Scale=31 is not a valid setting.

Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios