generic table class?

H

hamilton_denning

Greetings,

I'm trying to figure out an implementation for a class that will store
the contents of a ResultSet after the database connection has closed.
Basically, I want this data structure to have getColumn, getRow, and
getCell methods so that I can efficiently access the data any which
way. I've looked into extending AbstractTableModel, but I'm not sure
that this is the correct approach.

Can anyone point me to an existing implementation, or perhaps provide a
suggestion for how I would create one myself?

I greatly appreciate it!

-Ham
 
S

Sean Berry

Greetings,

I'm trying to figure out an implementation for a class that will store
the contents of a ResultSet after the database connection has closed.
Basically, I want this data structure to have getColumn, getRow, and
getCell methods so that I can efficiently access the data any which
way. I've looked into extending AbstractTableModel, but I'm not sure
that this is the correct approach.

Can anyone point me to an existing implementation, or perhaps provide a
suggestion for how I would create one myself?

I greatly appreciate it!

Note:
Below SQLcolumns is the number of columns in the ResultSet, and SQLrows is
the number of rows in the ResultSet. I am a beginner and I am sure there
are better ways to do this.

------------

I am not very experienced with Java yet but you could probably use a 2
dimensional array that is SQLcolumns x SQLrows in size and store each value
from the ResultSet in each cell running in a while ResultSet.next().

You could also use the ResultSet.getArray(int c) in a loop and store each
Object Array in some other Parent Array - ending up with a one dimensional
Array storing one dimensional Arrays.

Then, for getColumn(N) you could return an array SQLcolumns long consisting
of the Nth object of each row, for getRow(N) you could just return the Nth
Object Array in your Parent Array. The getCell(N, M) methods would return
the Mth value of the Object Array in the Nth position of the Parent Array.
 
H

hamilton_denning

Thanks to everyone for your advice. Yes, since there is no GUI
requirement, I think that the multi arrays are probably the best
solution. (I would have liked something dynamic for the underlying
data structure, but I'm not using Java 1.5,and I think I'll get better
performance using the arrays anyway.)

Thanks again!

-Ham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top