I have an application which gets data from database and create excel. I wanted to separete dao class which gets the resultSet from db and the class which is creating excel with this resultset.
In this way I was passing ResultSet from Dao to the other class to create excel file. But when I run the rs.next(), it gives me "Closed Resultset:next" error. I read on the internet that passing ResultSet is not good idea therefore I just try to do it in dao class and it worked.
But in that way I do not like to do other task (creasting excel) in dao class and I do not want to create a class and then send them as a list. So my question is why it is bad to pass resultset to other class or function? Why I got exception when I pass it and try to call rs.next()?
To Summarize my code looks like these:
ResultSet rs = myDao.getResult();
ExcelCreator excelCreator = new ExcelCreator();
excelCreator.createExcel(rs);