I had written a service for querying data from SQL.
public class DummyDeviceTokenService {
Connection connect = null;
Statement statement = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
public DummyDeviceTokenService() throws Exception{
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager
.getConnection("jdbc:mysql://localhost/student?"
+ "user=root&password=root");
statement = connect.createStatement();
}
public ResultSet selectAll(int offset,int range)throws Exception{
resultSet = statement
.executeQuery("select * from employee where id > " + offset + " AND id < "+range);
return resultSet;
}
}
I want to return a stream from public ResultSet selectAll(int offset,int range)
.
I went through java.util.stream with ResultSet - Stack Overflow but these were little complex methods.
Please suggest some good way to do this.