How do i show all the values in one window(JOptionPane)??
I have the following code:
Code :
try
{
Class.forName("com.mysql.jdbc.Driver");
conec = DriverManager.getConnection("jdbc:mysql://localhost/Inventory","root", "");
est=conec.createStatement();
res=est.executeQuery("SELECT id_client,name_client,date FROM client");
[B]while(res.next())
{
idClient1=res.getString("id_client");
NameClient=res.getString("name_client");
Date1=res.getString("date");
JOptionPane.showMessageDialog(null, "Document: "+idClient1+"\nName: "+NameClient+"\nDate: "+Date1);
}[/B]}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
the problem is that it shows the values but i have to click on accept to continue with the next one, How do i show all the values in one window?
THANKS...
Re: How do i show all the values in one window(JOptionPane)??
The easiest method is to create string that has all the information in it:
Code :
// replace the bold stuff with this
String toDisplay = "";
while (res.next())
{
idClient1=res.getString("id_client");
NameClient=res.getString("name_client");
Date1=res.getString("date");
toDisplay += "Document: "+idClient1+"\nName: "+NameClient+"\nDate: "+Date1 +"\n\n";
}
JOptionPane.showMessageDialog(null,toDisplay);