Thread

  1. can u help me

    JACOB SIBI <js022@gre.ac.uk> — 2001-04-02T18:49:39Z

    Hi,
    I have a probelm with my JDBC coding. Iam using a Java  swing interface
    to input data. It reads in studentID from the textField and should
    output the average.The code compliles well. But i get the average as 0,
    with exceptions as detailed below.
    
    The error I get is
    java.sql..SQLException:[Microsoft] [ODBC Driver Manger]  Invalid cursor
    state.
    
    
    This is the code that creates the error.
    
     public void FindAverageStudent()
               {
                int marksPE2=0;
                int marksSE1=0;
                int marksEA=0;
                int average=0;
                int TotalMarks=0;
                int StudID=Integer.parseInt(StudentIDField.getText());
    
                try
                {
                Statement stmt = connection.createStatement();
                ResultSet rs = stmt.executeQuery(
                "SELECT * FROM Student2 " + " WHERE Student_ID = '" +
    StudentIDField.getText() + "'");
    
    
                  marksPE2=rs.getInt(4);
                  marksSE1=rs.getInt(5);
                  marksEA=rs.getInt(6);
                  TotalMarks=marksPE2+marksSE1+marksEA;
                  average=TotalMarks/3;
                  connection.close();
                }
                catch(SQLException sqlex)
                {
                sqlex.printStackTrace();
                }
                Area1.append("The average marks of the student is "+
    average);
              }
    
    
    
    Hope to hear from you,
    
    
    My emailid is jacobspj@hotmail.com
    
    jacob