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

    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();

        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);

        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.

The structure looks like this (pseudo cde)

// do your initialisation
do {
   // do one transaction
   answer = ask user "do another?"
} while (answer is yes);
This article has been dead for over six months. Start a new discussion instead.