The ResultSet
object is the interface provided by Java JDBC - they do not provide an implementation. Despite the fact that your specific database code and related drivers implement ResultSet
so that you can name it several times for each result, if you depend on such behavior that is outside the contract, you are definitely playing with fire.
One of the possible reasons the contract was written using the string this method should be called only once per result
, for efficiency reasons. Building a ResultSet is likely to trigger a JCBC RPC call into the database, and the JDBC spec authors would like to beat off multiple trips. Perhaps they did not want to force the performers to effectively protect against several calls for the result. Again, even if your database protects against this behavior, this does not mean that the next will be.
Most ResultSet
implementations also support connecting to an open database, so when you get certain fields (like big drops), it can call back to the database to receive the data. Having multiple connections open or (worse) using the same connection from multiple ResultSet
objects will be very dangerous / confusing.
In addition, they may have been bothered by the two parts of your code calling getResultSet()
twice, and references to the same single unsynchronized object were returned. This can cause confusion when calling next()
and overwrite the object with multiple references.
I think, of course, but I hope this helps.
source share