Hello. I'm somewhat new to all of this, so forgive me if this is something really basic.
I'm developing an application which must interact with my MySQL database pretty frequently, however it seems to me that I am unable to, essentially, have multiple ResultSets open at a given time, which as a result prevents me from making multiple queries simultaneously. The essential problem is...
ResultSet rs = statement.execute( "SELECT * FROM table");
if (rs.next())
{
ResultSet srs = statement.execute( "SELECT * FROM table2");
rs.getInt("id");
}
...Yields a NullPointerException on line 5. If I am correct in my understanding, this is due to a ResultSet closing when it's statement is used a second time.
My best guess to solving this problem is to create a pool of statement objects (which would essentially be a number of connections to the DB), and then use the first open statement object (or a newly created one) to run a particular query... however this seems rather sloppy. Not to mention that, offhand, I'm not even sure if I can have multiple connections open to the DB at the same time. Is there any better way to run multiple queries at the same time with JDBC?
Thanks in advance for any help.
-Jess