I am trying to Download image (.png) file from MYSQL. some time it works fine.unable find exact problem. it works properly on Jboss server. throws an error while trying to r
The second result.next
is moving you past the end of the result set.
I think you want
result = st.executeQuery();
if(result.next()){
input = result.getAsciiStream(1);
}
You are calling result.next()
twice. I'm assuming that your query returns only 1 row since you are trying to match by Userid
. When the second result.next()
is being called, there is no row to be returned in the ResultSet
. This is why an SQLException
is being thrown. Remove the 1st result.next()
like so:
result = st.executeQuery();
if(!result.next()){
input = result.getAsciiStream(1);
}