I am developing 2 application who are reliated to the same database. I use java swing and I want to update my Frame when the database is updated from the other application. I tried to write my code in a loop using
while (this.isVisible())
But it doesn't work. My code:
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con= DriverManager.getConnection("jdbc:mysql://localhost/Base", "root", "");
PreparedStatement pstmt = con.prepareStatement("SELECT enter from table where person =? ");
pstmt.setString(1,"responsable");
ResultSet rs= pstmt.executeQuery();
while (this.isVisible()){
while(rs.next()){
if (rs.getInt("enter")==0)
{
jLabel13.hide();
jLabel10.setVisible(true);
}
else
{
jLabel10.hide();
jLabel13.setVisible(true);
}}}
JFrame
s in the same application?