ResultSet Functions Problems

Hi friends,

I’m getting results from database like below but ResultSet function does not behave normal :slight_smile:
for example I have table which contains authors. datas in it:

AuthorID AuthorName

1 Tom Robbins
2 John Fowles
3 Paul Auster
4 J.R.R Tolkein

I believe that I can get the all datas which are in table with using this

ResultSet rs = stmt.executeQuery("SELECT * FROM authors");

I believe because in debug mod I can’t find datas in rs - there are lots of things in rs :confused:

after getting datas to rs, is reading datas three by three in while loop (or sometime seven by seven if there is more datas then this example )
(first entering to loop) first output is “Paul Auster” which should be “Tom Robbins”
(second entering) bamm, output is “SQLException: After end of result set”

I think it is trying to read sixth data in rs, but why?

any suggestions???

thanks lot,

try {			

			// create a connection to the db
			Connection conn = DriverManager.getConnection(
					"jdbc:mysql://localhost/books", "root", "11111");

			// get some results
			Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
			ResultSet rs = stmt.executeQuery("SELECT * FROM authors");
			while ( {
				System.out.println( rs.getString("AuthorName") );

		} catch (SQLException ex) {
			// handle any errors
			System.out.println("SQLException: " + ex.getMessage());
			System.out.println("SQLState: " + ex.getSQLState());
			System.out.println("VendorError: " + ex.getErrorCode());