Are you sure the variables s and m have values? Not knowing your table columns, is there a "line" column? Try "select line from..." too. Are there rows returned in the DB? If not then the result set should be null and the while loop doesn't execute.
Also you should consider passing the variables s and m into the prepared statement rather than concat to sql.
Oh for best practice, you should do the close connection, result set stuff in the finally block.
1) Your where condition is not matched by any row in the table. The while(rs.next()) loop is never entered and the value of i is never changed from its initial value of 0.
2) There are several rows that match the where condition. The database gives them in some order and it just happens that the last row returned by the query has a value of 0 (or NULL - see javadoc!) in the line column. The last encountered value remains stored in i after the loop terminates and is printed.
To find out which of these two possibilities is happening, just move the System.out.println(i); into the loop - it will print all values fetched from the database. If it prints nothing, it's the first case. If it prints something, at least you'll see which values and in which order are selected. Add call to rs.wasNull() to see whether the returned value was NULL or not.
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad: