resultset an iterator?

M

mistral

Hello,

1)If a execute a statement : SELECT * FROM balaba.
And I retrieve this statement as a resultset. Then is this result set
totally filled with the table => the resultset contains the whole table
blabla.
OR is this just an interator and every time I do a next the database is
contacted and the next record  is retrieved.

This is important because you don't want a whole db table in your memory :)

2) Is the com.mysql.jdbc.resultset better than java.sql.resultset?


Thanks !


Tom
 
M

Michael Borgwardt

mistral said:
Hello,

1)If a execute a statement : SELECT * FROM balaba.
And I retrieve this statement as a resultset. Then is this result set
totally filled with the table => the resultset contains the whole table
blabla.
OR is this just an interator and every time I do a next the database is
contacted and the next record is retrieved.

That's an implementation detail of the JDBC driver.
This is important because you don't want a whole db table in your memory :)

You don't want a network roundtrip for each single row either, that would probably
be worse in most cases. A good JDBC driver should fetch the rows in reasonable
chunks (maybe 100) at a time. This is even configurable somewhere in JDBC, but
I remember reading somewhere that most JDBC drivers do indeed fetch the entire
table, and it's not that much of a problem. After all, you very rately do an
unqualified select on a really big table - what would you do with the result,
after all?
2) Is the com.mysql.jdbc.resultset better than java.sql.resultset?

I suspect that it is simply an implementation of java.sql.resultset, which
is an interface.
 
M

mistral

Michael said:
That's an implementation detail of the JDBC driver.


You don't want a network roundtrip for each single row either, that would
probably be worse in most cases. A good JDBC driver should fetch the rows
in reasonable chunks (maybe 100) at a time. This is even configurable
somewhere in JDBC, but I remember reading somewhere that most JDBC drivers
do indeed fetch the entire table, and it's not that much of a problem.
After all, you very rately do an unqualified select on a really big table
- what would you do with the result, after all?

I suspect that it is simply an implementation of java.sql.resultset, which
is an interface.

Ok thank you !
 
M

mistral

mistral said:
Hello,

1)If a execute a statement : SELECT * FROM balaba.
And I retrieve this statement as a resultset. Then is this result set
totally filled with the table => the resultset contains the whole table
blabla.
OR is this just an interator and every time I do a next the database is
contacted and the next record  is retrieved.

This is important because you don't want a whole db table in your memory
:)

2) Is the com.mysql.jdbc.resultset better than java.sql.resultset?


Thanks !


Tom


The solution for this problem is discussed in comp.lang.java.databases.
 

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
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top