java在数据库更新时更新我的JFrame
我正在开发两个应用程序谁是依赖于同一个数据库。 我使用JavaSwing,希望在从其他应用程序更新数据库时更新框架。 我尝试使用
while (this.isVisible())
但它不起作用。 我的代码:
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);
}}}
共 (0) 个答案