On Fri, 19 Dec 2003 10:38:18 -0800 (PST), Jeremy Kruer
<jkruer01@...> wrote:
>I noticed that when you run a query on a table, it
>only returns the first 500 rows, which I assume is for
>speeds sake, which I understand. However, I have
>found one problem. =20
>
>Say you want to export all rows in a table that has
>10,000 records. If you run a blank Query and then
>choose Query Form > Export > All Rows, it only exports
>the first 500 rows. If you scroll all the way down to
>the bottom of the Grid View and get all 10,000 records
>to display in the Grid View then it will export all
>10,000 records. =20
>
>It seems to me that if you choose "All Rows" it should
>export every row in the table instead of just the ones
>that are displayed in the Grid View.
>
>As I mentioned before, I am trying to learn Java, so I
>started looking through the code to find where this is
>occuring. I know that the method that exports the
>rows is exportInsertStatements in the ExportManager
>class. I also know that the method is being called
>from the exportResultSet method in the MainPanel
>class. =20
>
>The ResultSet that is being passed to the method is
>coming from the BaseForm class, but from there is
>where I start to get lost.
>
>Would it be better to pass the Full ResultSet to the
>exportInsertStatements method if "All Rows" is
>selected, or would it be better to pass a null to the
>method and then have the exportInsertStatements method
>check for a null value and if it is null then get the
>complete ResultSet?
What's getting passed to the exportInsertStatements method is not a
java.sql.ResultSet (even though it's called "resultSet") but actually
a List of Vectors. Each Vector in the List represents a row on the
table. This List is backed by a Vector[] array that comes from the
org.glasser.sql.ResultSetBuffer.getCurrentRowset() method. (The
BaseForm contains a ResultSetBuffer which actually contains and
manages the ResultSet.) The List of Vectors is a *copy* of the current
contents of the ResultSetBuffer.
The ExportManager class doesn't know anything about
java.sql.ResultSets, or any of the classes in org.glasser.qform for
that matter, and that's a good thing. If you want to export all of the
rows in the current ResultSet, you have to read them into the
ResultSetBuffer before this line in MainPanel.exportResultSet() is
executed:
Vector[] currentRowset =3D qp.getCurrentRowset();
One way to do that would be:
while( ! resultSetBuffer.isEndOfResultsReached() ) {
// get the last row in the buffer which will cause it
// to read in more rows.
resultSetBuffer.getRowAt(resultSetBuffer.size() - 1);
}
But since MainPanel doesn't have direct access to the BaseForm or the
ResultSetBuffer, you'll have to add a method to QueryPanel that calls
a method on BaseForm that contains the above code. So the code in
MainPanel would look like:
qp.readInAllRows(); // new method in QueryPanel class
Vector[] currentRowset =3D qp.getCurrentRowset();
and then you would be exporting all rows.
The reason I wouldn't do that myself is that I'm very wary of adding
any code that would cause an entire resultset to be read into the
buffer at one time. If it's only 1000 or so rows, it's no big deal,
but in a production database, if you're not careful you could find the
program frozen while it's reading in a million or more rows, until it
finally runs out of memory and crashes.
What I might do in the next release is check to see if all of the rows
have been read into the buffer when the user does an "export all", and
pop up a confirm dialog if they haven't. That way you could cancel and
read them in manually. Another thing I'd like to add someday is a
toolbar button or something that makes it easier to read all of the
rows in without having to move the scrollpane slider up and down
repeatedly.
>
>Again, I am a newbie still so don't be harsh if what I
>said makes no since.=20
Don't worry about it. You can't learn Java without writing Java code,
and I know from experience it's often hard to make changes to someone
else's code if they're not available to ask them questions.
Are you using ant to build QueryForm with? If not, I highly recommend
it. The build.xml is set up to make it really easy. After you unzip
the qform-1.3b-src.zip file, put all of the library jar files (that
are in the same directory as the qform.jar file that you run the app
from) and simply run the command:
ant compile
to compile the code, or
and buildjar
to build qform.jar.
|