1. Home >
  2. Computers & Internet >
  3. Programming & Design >
  4. Undecided Question
vaishali vaishali
Member since:
04 November 2009
Total points:
95 (Level 1)

Undecided Question

Show me another »

I hav only one recordset value.....but still i get Invalid cursor state error....how to solve it?

here is my code......wen i give condition in query i get only one record set ....code:
Connection con;
Statement st;
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcD…
con=DriverManager.getConnection("jdbc:od…
st=con.createStatement();
ResultSet rs;
try
{
System.out.println(empid.getText());
String myq="select * from employee where empid='"+empid.getText()+"'";
System.out.println(myq);
rs=st.executeQuery(myq);

String ei = rs.getString(1);
System.out.println(ei);
}
  • 3 weeks ago
  • (Tiebreaker)

Answers (1)

  • Answerer 1

    You are missing rs.next(); Try adding it here

    rs=st.executeQuery(myq);
    rs.next(); //<------add here
    String ei = rs.getString(1);
    System.out.println(ei);
    • 3 weeks ago

None of these answers doing it for you?

Sometimes none of the answers get it just right. If so, pick "No Best Answer". Voters DO NOT get any points for voting on the No Best Answer.

Answers International

Yahoo! does not evaluate or guarantee the accuracy of any Yahoo! Answers content. Click here for the Full Disclaimer.

Help us improve Yahoo! Answers. Tell us what you think.