------------ Ok thats it.. now i know the database is fine and everything since i have connected to it before. The error i get when i try runing this is "Invalid cursor state" which i have no idea what that is. So can i please get some urgent help on this? I know the loop is pretty wierd lol , is there a better way? What i have is a database table with and ID for first coloumn and Firstname for second colom. I want it to add all the names in that table to a string variable names[] and then stop when its all done.. this is the only way i see it working but im sure there is a better way. Thanks alot.. and the sooner the help the better.!!!
Firstly, passing ResultSets around is pretty bad form. You're better off converting from your database representation to an Object representation as quickly as possible, and then doing Java-only stuff from that point on. The problem you are having is that the ResultSet cursor starts at a 'before first' position. That is, until you call 'rs.next()', you aren't looking at the first record. That's why almost all ResultSet loops you see will start with 'while( rs.next() )'. Dave ps: use the code tags to format your code. It helps us help you!
ok thx, i found were my problem really lies (other then the part you guys helped me fix). my aray is messed up..hmm Can u please tell me how to make an array and declare it so it can carry an infinite amount.. all i do is go String names[]; but theres more right? plz show me =] thx
Jason Steele
Ranch Hand
Joined: Apr 25, 2003
Posts: 100
posted
0
Kevin, Glad you got it fixed... If you want a dynamic array, you can use ArrayList. It will allow your data to grow. Also, you can easily convert it to a standard array if needed.