import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;


public class Main
{
public static void main (String[] args) throws Exception

{
    Class.forName("com.mysql.jdbc.Driver");
    Connection con =  DriverManager.getConnection("jdbc:mysql://localhost:3306/convocation","root","");


    //ImageIcon icon = new ImageIcon("C:\\Users\\a\\workspace\\MysqlName\\img\\U.png");

    //JOptionPane.showMessageDialog(null, "Custom", "Custom Image", JOptionPane.INFORMATION_MESSAGE, icon );

    int id_convo= Integer.parseInt(JOptionPane.showInputDialog(null,"Please Insert Student Convo ID\n(eg:01,02,03)", "U CONVOCATION" ,JOptionPane.INFORMATION_MESSAGE));

    PreparedStatement statement = con.prepareStatement("select * from stud_details where id='"+id_convo+"' ");
    //statement.setInt(1, id_convo);
    ResultSet result = statement.executeQuery();

    while(result.next())
    {
        JOptionPane.showMessageDialog(null, result.getString(1) + "\n "+result.getString(2) + "\n " +result.getString(3)+ "\n " +result.getString(4));
    int y = JOptionPane.YES_NO_OPTION;
         y = JOptionPane.showConfirmDialog(null, "Continue",null,y);

    if (y ==JOptionPane.YES_OPTION){
        JOptionPane.showInputDialog(null,"Please Insert Student Convo ID\n(eg:01,02,03)", "U CONVOCATION" ,JOptionPane.INFORMATION_MESSAGE);

    }
    else
    {
        JOptionPane.showMessageDialog(null, "End");
    }
    while (y!= JOptionPane.NO_OPTION);

    }

}

}

how to do a loop, after user click yes to continue. and it ask back to input the convo id. it will asked until the user click no.
thanks

The structure looks like this (pseudo cde)

// do your initialisation
do {
   // do one transaction
   answer = ask user "do another?"
} while (answer is yes);

what exactly is the use of this statement in your code ?
while (y!= JOptionPane.NO_OPTION);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.