I want to show a progress bar dialog box of my application importing to database from a csv file, using a while loop -
Here is my code -
try
{
BufferedReader br=new BufferedReader(new FileReader("temp.csv"));
String line;
line=br.readLine();
while((line=br.readLine())!=null)
{
String[]value = line.split(",");
String sql = "INSERT into main ([Ticket #], Status, Priority, Department, [Account Name]) "
+ "values ('"+value[0]+"','"+value[1]+"','"+value[2]+"','"+value[3]+"','"+value[4]+"')";
System.out.println(sql);
PreparedStatement pst = null;
try{
pst = db.prepareStatement(sql);
pst.executeUpdate();
}finally{
if(pst != null){
pst.close();
}
}
}
br.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
}
I want a progress of my while loop in execution.