let's start here:
int[] mainArray = {};
you say that mainArray is an array without elements, and later on, you try to store information in the array for indexes it doesn't have.
an option would be:
int[] mainArray;
int y = getNumberOfElementsForArray();
mainArray = new int[y];
or you could use an arraylist. that way you don't need to know up front the number of elements your array should be able to hold.
if you have any more errors, could you tell us what errors they are? not all of us have much time to go over all of your code.
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
You must call rs.next() to advance through your result set. Initially your row pointer is positioned before the first result.
Typically you will use if(rs.next()) or while(rs.next()) to advance while there are records to read.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847