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!

Display multiple resultSet values in one JOptionPane.INFORMATION_MESSAGE

843859Oct 26 2008 — edited Nov 20 2014
Hi. I need help with displaying my resultSet values in ONLY ONE JOptionPane.INFORMATION_MESSAGE.

Here's my code so far ( extracted from my whole program ):

else if ( rb4.isSelected() )
{
	resultSet = statement.executeQuery( "select * from agents" );

	while ( resultSet.next() )
	{
		JOptionPane.showMessageDialog( this, resultSet.getString(1) + resultSet.getString(2)
			, "List All Agents", JOptionPane.INFORMATION_MESSAGE);
	}
}
What happens at the moment is with EVERY single row in mySQL database table, it displays one JOption pop-up.
So if I have 4 rows in my table agents, there's four message pop-ups.

I want it to diplay the WHOLE table in ONE message pane.
Can anyone PLEAAAASEEE help me?

I'm at my wits end. Almost everything works fine, except for that.
I mean, I can connect to my database, and call everything and stuff like that.

Thank you so much!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2008
Added on Oct 26 2008
7 comments
484 views