Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query only returns one row, when multiple rows exist in MySQL database

843859Dec 8 2009 — edited Dec 14 2009
Hey all,

I am using:

Database: MySQL 5.0
JDBC Driver: mysql-connector-java-5.0.8-bin.jar

Running this method, which I believe should return each row upon each iteration, but does not.
if(resultSet.next()) {
	do {
			
		Console.print("Webpage title: " + resultSet.getString("Title"));
									
	}
	while(resultSet.next());
When I run the query in my DB tool, 3 rows are retrieved as expected
When I run the code in java, just one row is retrieved.

Any ideas? Spent two evenings trying to figure this out but I'm stumped!

Thanks!

WM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2010
Added on Dec 8 2009
9 comments
762 views