add max result row restriction

- use Statement.setMaxRows() to limit the max. no. of rows returned 
- removed the unnecessary processing to removed the ending ";" for user
provided query.
- use more meaning variable name instead of i
- fixed "zigzag" code due to eclipse autoformat to max length of 80