I'm guessing by lines you mean rows in your database. If you're using MySQL you can limit the results.
SELECT * FROM yourDB LIMIT 0,100;
//or db2
SELECT * FROM yourDB FETCH FIRST 100 ROWS ONLY;
or you can exit out of your loop after 100 iterations.
Not sure if that's what your looking for. maybe post the code you have.
j