Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3942812
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:42:27+00:00 2026-05-20T00:42:27+00:00

my code works fine but I am getting this exception a lot and it’s

  • 0

my code works fine but I am getting this exception a lot and it’s causing a little lag … I suspect this part to produce the exception

try {
        try {
            rs = dbConnection.getStatement().executeQuery("SELECT * FROM healthgym.member WHERE member_id = " + id);
            rs.next();
        } catch (SQLException ex) {
            Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
        }
        m.setMember_id(rs.getInt("member_id"));
        m.setRec_id(rs.getInt("rec_id"));
        m.setTrainer_id(rs.getInt("trainer_id"));
        m.setFname(rs.getString("fname"));
        m.setLname(rs.getString("lname"));
        m.setMname(rs.getString("mname"));
        m.setEmail(rs.getString("email"));
        m.setPhoneNo(rs.getInt("phoneno"));
        m.setAge(rs.getInt("age"));............

I use the m object later to fill some text fields

Edit 1 : I am still getting that exception … here is what happens exactly … I select a row in Jtable and I press the edit button the exception is thrown but it works fine
here is what’s called when i press the edit button

  private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
    // TODO add your handling code here:
    int id = ((Number) model.getValueAt(jTable1.getSelectedRow(), 0)).intValue() ;
    System.out.println(id);

      m = new Member();
    c.getMember(m,id);

    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new EditMember(c,model,m).setVisible(true);
        }
    });


}       

And EditMember is a GUI here is its constructor..

public class EditMember extends javax.swing.JFrame {

/** Creates new form EditMember */
public EditMember(Controller c, ResultSetTableModel model , Member m) {

    initComponents();
    this.c = c;
    this.model = model ;
    this.m = m ;
    memberID.setText(Integer.toString(m.getMember_id()));
    recID.setText(Integer.toString(m.getRec_id()));
    trainerID.setText(Integer.toString(m.getTrainer_id()));
    fName.setText(m.getFname());
    lName.setText(m.getLname());.......

Edit 2 :

That;s where the exception happens :

public Object getValueAt( int row, int column )
  throws IllegalStateException


  {
      // ensure database connection is available
      if ( !dbConnection.isConnectedToDatabase() )
         throw new IllegalStateException( "Not Connected to Database" );
  // obtain a value at specified ResultSet row and column

  try
  {
     resultSet.absolute( row + 1 );
     return resultSet.getObject( column + 1 );
  } // end try
  catch ( SQLException sqlException )
  {
      System.out.println("Exception from here dude");
     sqlException.printStackTrace();
  } // end catch

I guess the problem is because I am using the same resultset that I used before to construct the JTable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:42:28+00:00Added an answer on May 20, 2026 at 12:42 am

    it should be

        if(rs.next(){
      m.setMember_id(rs.getInt("member_id"));
    }
    

    So all set value will be in try block.

    Why you are getting error ?
    Because sometime when result is empty the result set will be closed by rs.next()

    If you put it in while {where there are multiple row in result of query} or if {when you accept only one row in query output }.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works fine to find an available room within certain date, but it
This code works fine in C#: Expression.Lambda(LambdaBody); But none of the methods for building
Normally, this code works completely fine, but I have a single instance on a
the code below works fine but it takes an absolute age to run. How
Currently my code below works fine but it's a bit of overkill. In my
The code I have below works fine but I'm sure it could be more
I have some code that works fine in FF but not in IE. I
The following code works fine in most browsers but it won't work in Internet
My code works fine when I call AA.sendRequest() from the console, but not when
I've got some code which works fine in IE but unfortunately not in Google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.