Questions tagged [resultset]

A result set is a set of rows from a database, which is usually generated by executing a statement that queries the database. A resultSet object maintains a cursor pointing to its current row of data.

A result set is a set of rows from a database, which is usually generated by executing a statement that queries the database. A resultSet object maintains a cursor pointing to its current row of data.

2543 questions
21
votes
2 answers

Can I view a resultset in Eclipse debugger as a table

I have a resultset in Eclipse created from an SQL query. Coming from the world of Visual Studio, I expected to find a watch view of my variable that shows me the resultset as a table instead of just showing all the fields and properties. Does such a…
thedrs
  • 1,412
  • 12
  • 29
20
votes
10 answers

Where to close a JDBC Connection while I want to return the ResultSet

It seems that the ResultSet will be automatically closed when I close the Connection. But I want to return the ResultSet and use it in another method, then I don't know where to close Connection and PreparedStatement. public ResultSet…
Aloong
  • 1,715
  • 6
  • 23
  • 40
20
votes
3 answers

Does reusing a Statement and Resultset release resources from its previous usage? Or do I have to explicitly close them before reuse?

Sample code: aStmt = aConn.prepareStatement(aQuery); aRset = aStmt.executeQuery(cQuery); while (cRset.next()) { //stuff to determine value of parm1 aStmt.setString(1, parm1); …
heisenbergman
  • 1,459
  • 4
  • 16
  • 33
20
votes
5 answers

Retrieve entire row with ResultSet

Is it possible to retrieve entire row without calling getInt(..) getString(..) for every column? I have multiple threads, each tread needs to write the result to some thread safe collection. I want to be able to write the rows directly to this…
yuris
  • 1,109
  • 4
  • 19
  • 33
19
votes
5 answers

Getting Boolean from ResultSet

ResultSet#getBoolean seems to return false when it's null. Is there an easy way to get a Boolean (not boolean) from a ResultSet?
Priv
  • 812
  • 2
  • 9
  • 23
19
votes
5 answers

Get MySQL Query Results as Their Native Data Type?

I have tried fetching MySQL query results using mysql_fetch_row() and mysql_result() and numeric values are being returned as strings. Is there any way to fetch the data as its datatype stored in the table? The application will be querying many…
user292089
19
votes
3 answers

Retrieving Multiple Result sets with stored procedure in php/mysqli

I have a stored procedure that has multiple result sets. How do I advance to the 2nd result set in mysqli to get those results? Let's say it's a stored proc like: create procedure multiples( param1 INT, param2 INT ) BEGIN SELECT * FROM table1 WHERE…
MacAnthony
  • 4,471
  • 2
  • 23
  • 26
18
votes
2 answers

Fetch Oracle table type from stored procedure using JDBC

I'm trying to understand different ways of getting table data from Oracle stored procedures / functions using JDBC. The six ways are the following ones: procedure returning a schema-level table type as an OUT parameter procedure returning a…
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
18
votes
2 answers

How to mock jdbc connection and resultSet using Mockito in TestNG

I have to write some unit tests but I have problem with mocking ResultSet and jdbc Connection. I have this method: @Test public void test3() throws SQLException, IOException { Connection jdbcConnection = Mockito.mock(Connection.class); …
kosmit
  • 621
  • 2
  • 7
  • 23
18
votes
4 answers

Oracle doesn't remove cursors after closing result set

Note: we reuse single connection. ************************************************ public Connection connection() { try { if ((connection == null) || (connection.isClosed())) { if (connection!=null) …
Vladimir
  • 4,782
  • 7
  • 35
  • 56
18
votes
4 answers

Why does my code produce the error: The statement did not return a result set

I am executing the following query from Microsoft SQL Server Studio, which works fine and displays results: SELECT * INTO #temp_table FROM md_criteria_join WHERE user_name = 'tecgaw' UPDATE #temp_table SET user_name = 'tec' WHERE user_name…
user2966439
  • 307
  • 1
  • 5
  • 14
18
votes
1 answer

Reusing MyBatis ResultMap in multiple mapper.xml

I would like to re-use a specific from different *Mapper.xml files which all somehow read same objects. I have a Database table called Project, which I created the following resultMap for:
Alex Paransky
  • 295
  • 1
  • 3
  • 12
17
votes
2 answers

Unit testing a method that takes a ResultSet as parameter

How does one go about unit testing an object that can't be instantiated? Because currently I have a method that converts a ResultSet to an object but I'm unsure if this violates any programming principles. public CItem convert(ResultSet rs) { …
DGK
  • 2,947
  • 5
  • 32
  • 47
17
votes
1 answer

Does JDBC have a maximum ResultSet size?

Is there a maximum number of rows that a JDBC will put into a ResultSet specifically from a Hive query? I am not talking about fetch size or paging, but the total number of rows returned in a ResultSet. Correct me if I'm wrong, but the fetch size…
sparks
  • 736
  • 1
  • 9
  • 29
16
votes
2 answers

Resultset get all values

How can i get all the values from all the columns? Ive tried with this code: values.add(rs.getString(number)); Where number is the rowcount. But it only gives me all the values from the last column. I need to grab the values from every column and…
Looptech
  • 213
  • 2
  • 4
  • 12