Invalid cursor state
HI,i am a student from Malaysia
i am doing my JDBC project with my group members and i get the same problem as you all, that is === INVALID CURSOR STATE!!!!!!
what is this about? some one can explain this? define this statement? my 3 files got this kind of problem and cause me cannot delete record or update record... how to solve this problem? help!!!!!!!!!
below are my source code of the file
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class SearchSegmentPlanRecord implements ActionListener
{
private SegmentPlanScrollingPanel fields;
private JTextArea area;
private Connection connection;
public SearchSegmentPlanRecord (Connection c, SegmentPlanScrollingPanel f,JTextArea a)
{
connection = c;
fields = f;
area = a;
}
public void actionPerformed (ActionEvent e)
{
try
{
if(!fields.treecode.getText ().equals( "" ) )
{
Statement statement = connection.createStatement ();
String query = "SELECT * FROM SEGMENTPLAN "
+ " WHERE TREECODE = ' " +fields.treecode.getText().toUpperCase()+ " ' ";
area.append("\nSending Query: " + connection.nativeSQL (query) + "\n" );
ResultSet result = statement.executeQuery (query);
display ( result );
area.append( "\nQuery Successful\n");
statement.close();
}
else
area.append ( "\nEnter TreeCode then press Find\n" );
}
catch ( SQLException sqlex )
{
sqlex.printStackTrace();
area.append( sqlex.toString() );
area.setText("No Record Found");
}
}
public void display( ResultSet result )
{
try
{
result.next();
if ( !fields.treecode.getText().equals(""))
{
fields.segmentcode.setText(result.getString("SEGMENTCODE"));
fields.segmentcode.setEditable(false);
fields.treecode.setText( result.getString("TREECODE"));
fields.treecode.setEditable(false);
fields.numbertrees.setText( result.getString ("NUMBER_OF_TREES" ) );
fields.planteddate.setText( result.getString ("PLANTED_DATE" ) );
fields.officer.setText( result.getString ("FOREST_OFFICER" ) );
}
else
area.append( "\nNo Record found\n" );
}
catch ( SQLException sqlex )
{
sqlex.printStackTrace ();
area.append( sqlex.toString() );
}
}
}
Any one can correct this source code or not? this source code i have use in the another file (the first file) and it works!!. but after that , i duplicated other 3 files with the same source code above, and the error comes out!!!. how ? and why? some one can explain or any suggestion to fix it? one more thing i have to explain at here, i have used 4 tables in a database. then when i duplicate the source code for other 3 files, it cannot work at all, only for searching options. i still can use the Add function defined in anothe class. because of this error, i cannot search record, update record and delete record.
then my group member told me, if one file for database, which means in a database you only have a table for a particular file( i got 4 files, 1st file can work, and the rest all die!!!) , it won't cause the error of Invalid Cursor State. how this thing will happen? my project due date is next week... anyone have a better suggestion to solve this kind of situation.?
your suggestions and solutions are really really appreciated

