OK, if you are getting a
java exception, I would suggest increasing the size of the your JVM's heap memory (Remember the JDBC driver runs in your client JVM). The details are somewhat JVM specific (RTFM), but for the SUN JDK, you would use the -X non-standard JVM features (type java -X for a listing of them). Here are the ones you want to check with.
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
Another thing
you should probably keep in mind (note I know nothing about your table schema) is don't do a SELECT * as it will return everything. If you only need a few columns, it is much better to be selective and pick only the ones you need. Another option is to get a count first of the number of rows which meet your query.