my dog learned polymorphism
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

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(
at java.text.Format.format(
at javax.swing.JTable$DoubleRenderer.setValue(
at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(
at javax.swing.JTable.prepareRenderer(
at javax.swing.plaf.basic.BasicTableUI.paintCell(
at javax.swing.plaf.basic.BasicTableUI.paintCells(
at javax.swing.plaf.basic.BasicTableUI.paint(
at javax.swing.plaf.ComponentUI.update(
at javax.swing.JComponent.paintComponent(
at javax.swing.JComponent.paint(
at javax.swing.JComponent.paintChildren(
at javax.swing.JComponent.paint(
at javax.swing.JViewport.paint(
at javax.swing.JComponent.paintChildren(
at javax.swing.JComponent.paint(
at javax.swing.JComponent.paintToOffscreen(
at javax.swing.BufferStrategyPaintManager.paint(
at javax.swing.RepaintManager.paint(
at javax.swing.JComponent._paintImmediately(
at javax.swing.JComponent.paintImmediately(
at javax.swing.RepaintManager.paintDirtyRegions(
at javax.swing.RepaintManager.paintDirtyRegions(
at javax.swing.RepaintManager.seqPaintDirtyRegions(
at javax.swing.SystemEventQueueUtilities$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForFilters(
at java.awt.EventDispatchThread.pumpEventsForFilter(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: populate data from database into a jtable
jQuery in Action, 3rd edition