This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 122237 - CastException in PostgreSQL database Application
Summary: CastException in PostgreSQL database Application
Status: RESOLVED DUPLICATE of bug 105147
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Binding (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-18 21:57 UTC by vlllnz
Modified: 2007-11-20 13:38 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
error trace (4.73 KB, text/plain)
2007-11-18 21:59 UTC, vlllnz
Details
Screenshot (20.63 KB, application/pdf)
2007-11-18 22:00 UTC, vlllnz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vlllnz 2007-11-18 21:57:50 UTC
I have created a Java Desktop Application Database Application to work on a table "prova" using PostgreSQL 8.2.5.
When running the application, the "double" type columns are correctly visualized into italian format (decimal point 
comma), whereas the "numeric" type columns are incorrect (decimal point is not comma).
When trying to insert a new row I can't use the comma as a decimal point, but I have to use the decimal point.
When trying to enter a character in a "date" type column I get the error:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException

Connection parameters are
Basic settings
Name PostgreSQL
Driver org.postgresql.Driver
Database URL jdbc:postgresql://localhost:5432/test
User Name postgres

Advanced
Select schema public

The steps to create the application are
New Project
Java Desktop Application
Database Application
Database Connection jdbc:postgresql://localhost:5432/test [postgres on public]
Database Table prova
All columns included

SQL scripts are

CREATE TABLE prova
(
  id serial NOT NULL,
  stringa character varying,
  carattere character(1),
  doppia double precision,
  numero numeric(10,2),
  data date,
  timemod timestamp without time zone,
  CONSTRAINT prova_pkey PRIMARY KEY (id)
) 
WITHOUT OIDS;
ALTER TABLE prova OWNER TO postgres;
Comment 1 vlllnz 2007-11-18 21:59:01 UTC
Created attachment 53175 [details]
error trace
Comment 2 vlllnz 2007-11-18 22:00:54 UTC
Created attachment 53176 [details]
Screenshot
Comment 3 Jana Maleckova 2007-11-20 09:47:04 UTC
reassign to form
Comment 4 Jan Stola 2007-11-20 13:38:27 UTC
The generated application is using the default converters of Beans Binding library and renderers of Swing. The "double" 
column is translated to Double property of Prova class. JTable is using JTable$DoubleRenderer to render double values. 
This renderer is using NumberFormat, therefore it handles decimal separators correctly. The "numeric" column is 
translated to BigDecimal property of Prova.class. JTable is using JTable$NumberRenderer to render BigDecimals. This 
renderer doesn't use any formatter, it uses toString(), therefore it doesn't handle decimal separators correctly.

Finally the ClassCastException is caused by the fact that Beans Binding library doesn't have converter between String 
and Date. It is up to user to provide its own (using JTable customizer - see Table Contents action in contextual menu 
of JTable component). This situation is not ideal. Hence, we plan to provide a better support in this area, see issue 
105147.

*** This issue has been marked as a duplicate of 105147 ***