Need some help with ResultSet . ResultSet is an object that has a cursor, which in turn moves as it reads data from the table.

That is, in fact, it has no data, except for information about the cursor?

And how does fetchSize affect the ResultSet (what's interesting is not what the method does, but how it works in the context) because we only have data about the cursor in it?

  • This is a kind of collection stack, collected through a prepared request, for returning the sample and passing through it, if necessary. - And
  • @And Is it a collection? then we can therefore get outofmemory? - alex safsafsd
  • Naturally, returns a collection of sample rows. Of course, we can get OutOfMemory . This will reflect the overflowing memory buffer and you yourself will be able to make sure of it if you make a larger sample than is reserved for the result itself. Often this happens when there is more data than the memory allocated for the request. - And
  • @And Well, I’ve already answered below why I asked such a question. Answer the message, I'll put a plus sign to you. - alex safsafsd
  • And what's the point of an answer, if you have already chosen the right answer for you? - And

1 answer 1

That is, in fact, it has no data, except for information about the cursor?

No, this is not true.


The definition of ResultSet says:

What it is is a data table representing a database result set, which is usually generated by executing a statement that makes a query to the database.

getFetchSize() determines how many records the request reads, and is set in the Statement statement:

int getFetchSize () throws SQLException

Gets the number of rows in the result set, which is the default sample size for ResultSet objects generated from this Statement . If this Statement object does not set the sample size by calling the setFetchSize method, the return value will be implementation-specific.

  • Let's go first. That is, a ResultSer is a specific data set. By setting setFetchSize () we set a certain sample size (at a time). And if the table is ~ 1 000 000 without setFetchSize (), we just get an exception, from the driver about too large a ResultSet size. - alex safsafsd
  • The default sample size is set if the table will be ~ 1,000,000 without setFetchSize() . - Roman C
  • But by default, all data from a table can be returned. And while we still get an exception about too large a resalset? - alex safsafsd
  • the return value will be implementation - specific - Roman C
  • the return value will be implementation specific ..... RDMS. Right? - alex safsafsd