hi all, i am persistently getting the above-mentioned runtime error and at wit's end. This code is designed to get parameters from a html form, read data from two databases, and output to an xml file. Read Error: String index out of range: -1 For every 'customer' there are usually 3 addresses. It gets stuck while reading the address table on the second itiration. I believe this is where this error is generated. what am i doing wrong? ========*************==== [JUST WANTED TO TELL PEOPLE THAT I FIGURED IT OUT BY SLOW TRIAL AND ERROR. THE PROBLEM WAS SOME DATA MASSAGING WHERE I WAS TRYING TO TAKE OUT EXTRANEOUS DATA. MORE ON THAT IN THE JAVA GENERAL PAGE.]
========= this is the code fragment where i think the error is occurring.
It is important to realize that ResultSet.next() increments the cursor as well as returning the status. So your first "if", actually steps past the first column. A better solution might be:
As an aside, it is generally considered good practice to explicitly declare the fields you are retrieving from a query instead of using "select * from whatever". This helps make your code robust if you inadvertently change the ordering of the columns in the table, or add another column which is not used by this code. It also helps make your code more readable to reviewers, as we can see what should be in each column I hope this helps.
thanks for the response, Frank. turns out (as i noted in my editted message) that the problem was elsewhere. but thanks for the tips. i had totally forgotten that results.next increments the cursor. and i'll include the column names next time. thanks again. i love this board!! jay