1

Is it possible to get the result set data to single string (for writing to notepad)? Using record set we need to loop through each fields.

Is there any other way we can get to a single string without loop through each fields? I am able to do this in VBA by copying the entire recordset to an excel sheet.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Dinesh
  • 61
  • 1
  • 1
  • 11

2 Answers2

2

There isn't really something in standard Java that does this for you, except maybe using javax.sql.rowset.WebRowSet and one of its writeXml methods, but that is a very specific and verbose format.

If you want to output a result set in a specific format, you will need to do this yourself, or find a library that does this for you.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
0

Well, in general you have to convert a result set into an any DTO class whatever you want and then implement a toString() method in the way you want to be. There are some ways to achive this. Here is a one: Mapping a JDBC ResultSet to an object

Yuriy Tsarkov
  • 2,461
  • 2
  • 14
  • 28