this is what i am doing:
String[] output = new String[index.length];
try{
for(int i=0; i<index.length; i++){
Statement st = con.createStatement();
ResultSet res = st.executeQuery(
"SELECT url FROM resources WHERE rid = "+(index[i]);
while(res.next()){
output[i] = res.getString("url"); //<-- this is where exception is thrown
}
} catch(...)
The Method is working but instead of printing the correct url value, it is priting someting like this:
[Ljava.lang.String;@85af80
What does it mean? The url field in mySQL is VarChar, it worked fine with above methods but in this loop why i am getting the above result??
You haven’t initialized
output[]!Try this:
That strange output is caused by printing the array, ie
System.out.println(output);Try this instead:
It’s kinda lame, but java doesn’t automatically print the array contents, it prints the object type and address. The hint is the letter
Lat the start, which it uses to indicate an array