wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes populate data from database into a jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "populate data from database into a jtable" Watch "populate data from database into a jtable" New topic
Author

populate data from database into a jtable

Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74



I tried to populate data from database into a jtable ,but when i try this following error occurs
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.DecimalFormat.format(DecimalFormat.java:487)
at java.text.Format.format(Format.java:140)
at javax.swing.JTable$DoubleRenderer.setValue(JTable.java:5315)
at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(DefaultTableCellRenderer.java:223)
at javax.swing.JTable.prepareRenderer(JTable.java:5683)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2067)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1969)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1765)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
at javax.swing.JComponent.paintComponent(JComponent.java:758)
at javax.swing.JComponent.paint(JComponent.java:1022)
at javax.swing.JComponent.paintChildren(JComponent.java:859)
at javax.swing.JComponent.paint(JComponent.java:1031)
at javax.swing.JViewport.paint(JViewport.java:747)
at javax.swing.JComponent.paintChildren(JComponent.java:859)
at javax.swing.JComponent.paint(JComponent.java:1031)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5104)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1132)
at javax.swing.JComponent._paintImmediately(JComponent.java:5052)
at javax.swing.JComponent.paintImmediately(JComponent.java:4862)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:727)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:683)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:663)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Your JTable is setup to display some values as a number, but your data only contains Strings. That's not going to work. The Object[] should contain the values that are actually required; Boolean objects for boolean fields, Date objects for date fields, Double / Integer / Long objects for numeric fields, etc. Only use String objects for actual text fields.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: populate data from database into a jtable
 
Similar Threads
JTable Binding problem
updating database cause error
Deleting Row from JTable
regarding JTable data
Validate JTable edit