Parse boolean from Access db
Hi, I am trying to parse a boolean in from an access database and here's what happens.
1) When I populate the JTable that I'm using when the form initially loads, the table populates correctly.
2) After I edit information using JTextFields, I submit the query to update, which occurs with no issues
3) I then select all fields within the table using the SAME method as above, it throws the following error.
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String
The line of code its having trouble on is:
public Class getColumnClass(int columnIndex){
return types [columnIndex];
}
NOTE: This code is auto-generated by Netbeans and cannot be modified.
The following is my code which is used to populate the JTable:
publicvoid populateTable()
{
ResultSet newResults;
try{
myDatabase.loadDriver();
newResults = myDatabase.runQuery("SELECT * FROM User","search","null");
int columnID = 1;
int rowID = 0;
while(newResults.next() ==true)
{
while(columnID <= 3)
{
if (columnID == 2)
{
String temp = newResults.getString(columnID);
String output ="";
int i = 1;
while (i <= temp.length())
{
output = output +"*";
i++;
}
tblData.setValueAt(output, rowID, columnID - 1);
columnID++;
}
elseif (columnID == 3)
{
tblData.setValueAt(newResults.getBoolean(3), rowID, columnID - 1);
columnID++;
}
else
{
tblData.setValueAt(newResults.getString(columnID), rowID, columnID - 1);
columnID++;
}
//If all six columns of a row have been filled, move to the next row
}
columnID = 1;
rowID++;
}
}catch (ClassNotFoundException ex){
ex.printStackTrace();
}catch (SQLException ex){
ex.printStackTrace();
}
}
Any ideas? Thanks in advance.
Message was edited by:
bcwolfe
[3409 byte] By [
bcwolfea] at [2007-11-27 2:31:14]

Certainly. I didn't post it before since it's rather long. Here it is:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String
at javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(JTable.java:3614)
at javax.swing.JTable.prepareRenderer(JTable.java:3928)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1897)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:743)
at javax.swing.JComponent.paint(JComponent.java:1006)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4972)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
at javax.swing.JComponent._paintImmediately(JComponent.java:4868)
at javax.swing.JComponent.paintImmediately(JComponent.java:4675)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String
at javax.swing.JTable$BooleanRenderer.getTableCellRendererComponent(JTable.java:3614)
at javax.swing.JTable.prepareRenderer(JTable.java:3928)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2072)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1974)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1897)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:743)
at javax.swing.JComponent.paint(JComponent.java:1006)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paint(JComponent.java:1015)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
at javax.swing.JComponent.paintChildren(JComponent.java:843)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4979)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
at javax.swing.JComponent.paint(JComponent.java:996)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1709)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
at java.awt.Component.dispatchEventImpl(Component.java:4044)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)