about array length

please see the ???part, thanks first

boolean max_flag = false;
for(int p=0; max_flag == false; p++)
{
IObject[] unuseful = ImporterObjectManager.getUnusefulObjects("Tom",5000,p);
                                    
int sizee = unuseful .length; //?????????????????? I think sizee should always be 5000, but I got 5000,10000,7566,2566,0??what is wrong??????or I am wrong?
System.out.println(String.valueOf(sizee));
if(sizee== 0)
{
System.out.println(String.valueOf(sizee));
max_flag = true;
}
}

in other java file:

public static IObject[] getUnusefulObjects(String name, int record_per_page, int page)
      {                                         
            Connection conn            = null;
            PreparedStatement statement      = null;
            ResultSet resultset            = null;
            ArrayList <IObject> list      = new ArrayList<IObject>();
            
            String sql            = "SELECT * FROM my_table WHERE name = %s LIMIT %s, %s ";
            String[] args      = { name,
                        String.valueOf(record_per_page * page),
                        String.valueOf(record_per_page * (page+1)),
                          };
            
            sql= String.format(sql, args[0],args[1], args[2]);
            
            try
            {
                  conn      = ConnectionPool.getConnection(true);
                  statement      = conn.prepareStatement(sql);
                  
                  resultset      = statement.executeQuery();
                  
                  while (resultset.next())
                  {
                        int id= resultset.getInt(1);
                        
                        IObject obj      = new IObject(new Integer(id)); //coded in other java file
                        list.add(obj);
                  }
                  
                  return getObjectsFromList(list);  ////coded in other java file
            }
            catch (Exception e)
            {
                  writeErrorEmail(e);
            }
            finally
            {
                  Utilities.closeDBConnections(resultset, statement, conn);
            }
      
            return null;
      }
      

keepworkingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
looks like it should be as many rows are returned by the query
though depends what getObjectsFromList(list); does
0
objectsCommented:
          String.valueOf(record_per_page * page),
                    String.valueOf(record_per_page * (page+1)),

you multiple records_per_page (5000) by the page number
0
objectsCommented:
should be more like:

           String.valueOf(record_per_page * page),
                    String.valueOf(record_per_page),
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.