hi, i was supposed to write a program in jgrasp, using java, i am a grade 12 learner, my program needs to have gui, my program compiles with no errors, when i run it it gives me my error message - "problem with showdata" - and only fills the first two columns with data. I am writing an educational program teaching physical science, it is very frustrating, because usually when you compile it shows you more or less where where your problem is. please help. my program is due on monday.

gives me my error message - "problem with showdata"

Where does that error message come from. I don't recognize it as a java error.
Is it generated by the program? If so, no one can help you without seeing the code that generates the error messsage.
Do you get a stack trace with the error? If so copy and paste it here.
Does the code have any Exception catch blocks that do NOT call printStackTrace()?
If so, change them to call printStackTrace().

import javax.swing.*;
   import java.awt.*;
   import java.awt.event.*;
   import java.sql.*;

    public class Physics extends JFrame implements ActionListener
   {
      JTextField unitTxt;
      JTextField unitDescriptionTxt;
      JTextField unitFormulaeTxt;
      JTextField SIUnitTxt;
      JButton next;
      JButton previous;
      JButton exit;
      ResultSet rs;
    DataBM dbm = new DataBM();

       public Physics()
      {
         super("lesson");
         setBounds(600,600,700,620);
         setResizable(false);
         setDefaultCloseOperation(EXIT_ON_CLOSE);

         JPanel pane = new JPanel();
         pane.setLayout(null);

         JLabel unitLbl    = new JLabel("Unit:      ");
         JLabel UnitDescriptionLbl    = new JLabel("UnitDescription:      ");
         JLabel UnitFormulaeLbl  = new JLabel("UnitFormulae:         ");
         JLabel SIUnitLbl= new JLabel("SIUnit: ");
         unitTxt = new JTextField(500);
         unitDescriptionTxt = new JTextField(500);
         unitFormulaeTxt= new JTextField(500);
         SIUnitTxt= new JTextField(500);

         exit = new JButton("exit");
         exit.addActionListener(this);
        exit.setActionCommand("exit");
         next = new JButton("Next");
         next.addActionListener(this);
        next.setActionCommand("next");
        previous = new JButton("Previous");
         previous.addActionListener(this);
        previous.setActionCommand("prev");

         unitLbl.setBounds(20,20,200,30);
         unitTxt.setBounds(120,10,160,20);
         UnitDescriptionLbl.setBounds(10,40,100,20);
         unitDescriptionTxt.setBounds(120,40,160,20);
         UnitFormulaeLbl.setBounds(10,70,100,20);
         unitFormulaeTxt.setBounds(120,70,160,20);
         SIUnitLbl.setBounds(10,100,100,20);
         SIUnitTxt.setBounds(120,100,160,20);


         exit.setBounds(10,160,80,20);
         next.setBounds(100,160,80,20);
         previous.setBounds(190,160,80,20);

         pane.add(unitLbl);
         pane.add(unitTxt);
         pane.add(UnitDescriptionLbl);
         pane.add(unitDescriptionTxt);
         pane.add(UnitFormulaeLbl);
         pane.add(unitFormulaeTxt);
         pane.add(SIUnitLbl);
         pane.add(SIUnitTxt);


         pane.add(exit);
         pane.add(next);
         pane.add(previous);

         getData();
         showNextRecord();

         setContentPane(pane);
         setVisible(true);
      }

       public void getData()
      {
        rs = dbm.displayAllTopics();
          rs = dbm.displayAllLessons();
          rs = dbm.displayAllModules();
      }

       public void showNextRecord()
      {
         try
         {
            if(rs.next())
            {
               unitTxt.setText(rs.getString("Unit"));
               unitDescriptionTxt.setText(rs.getString ("unitDescription"));
               unitFormulaeTxt.setText(rs.getString ("unitFomulae"));
               SIUnitTxt.setText(rs.getString ("SIUnit"));
               java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");

            }
         }
             catch(SQLException sql)
            {
               JOptionPane.showMessageDialog(null,"problem with your data");
            }
      }
       public void showPreviousRecord()
      {
         try
         {
            if(rs.previous())
            {
               unitTxt.setText(rs.getString("Unit"));
               unitDescriptionTxt.setText(rs.getString ("unitDescription"));
               unitFormulaeTxt.setText(rs.getString ("UnitFormulae"));
               SIUnitTxt.setText(rs.getString ("SIUnit"));
               java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");

            }
         }
             catch(SQLException sql)
            {
               JOptionPane.showMessageDialog(null,"problem with your data");
            }
      }


    public void actionPerformed(ActionEvent ae)
    {
        JButton btn = (JButton) ae.getSource();
        if(btn.getActionCommand().equals("exit"))
        {
            dbm.close();
            System.exit(0);
        }
        else if(btn.getActionCommand().equals("next"))
        {
            showNextRecord();
        }
        else if(btn.getActionCommand().equals("prev"))
        {
            showPreviousRecord();
        }
    }

       public static void main(String[] args)
      {
         new Physics();
      }
   }

The above code shows examples of what I was talking about in my last post:
Does the code have any Exception catch blocks that do NOT call printStackTrace()?
If so, change them to call printStackTrace().

catch(SQLException sql)
{
JOptionPane.showMessageDialog(null,"problem with your data");
}

The above doesn't tell you what the error is!!!

Change it to:

catch(SQLException sql)
{
sql.printStackTrace();  //Show error message and stack trace
JOptionPane.showMessageDialog(null,"problem with your data");
}

----jGRASP exec: java Physics

java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:410)
at Physics.showNextRecord(Physics.java:98)
at Physics.<init>(Physics.java:79)
at Physics.main(Physics.java:151)

----jGRASP: operation complete.

THIS IS WHAT IT SHOWS ME AFTER printStackTrace();


----jGRASP exec: java Physics

java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:410)
at Physics.showNextRecord(Physics.java:98)
at Physics.<init>(Physics.java:79)
at Physics.main(Physics.java:151)

----jGRASP: operation complete.

THIS TOO. I DONT KNOW WHAT IT MEANS.


----jGRASP exec: java Physics

java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:410)
at Physics.showNextRecord(Physics.java:98)
at Physics.<init>(Physics.java:79)
at Physics.main(Physics.java:151)
java.sql.SQLException: Column not found
at sun.jdbc.odbc.JdbcOdbcResultSet.findColumn(JdbcOdbcResultSet.java:1849)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:410)
at Physics.showNextRecord(Physics.java:98)
at Physics.actionPerformed(Physics.java:141)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5501)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5266)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
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)

----jGRASP: operation complete.

Have you even bothered to read it? It says: "Column not found".
Now what do think could be the problem? Also the error message tells you exactly the line where that error occurred.

It is not that difficult to understand that you are trying to read a column that doesn't exist.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.