外部のmysqlデータベースからのデータを使用するswingアプリケーションがあります。
これらのデータを最新の状態にしたいので、新しいデータが利用可能かどうかを10秒ごとにチェックするスレッドがあります。
これが私のコードです:
public void run() { maj.getIgor().open(); // open the connection to Mysql while (true) { try {
            if (maj.getIgor().getConnexion().isValid(2)) {
                maj.checkProduits(); // update the datas
            } else {
                maj.getIgor().close();
                maj.getIgor().open();
                System.out.println("Re-try to open connection");
            }
            ThreadIgor.sleep(10000);
        } catch (SQLException ex) {
            Logger.getLogger(ThreadMajProduits.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InterruptedException ex) {
            try {
                Thread.currentThread().interrupt();
                maj.getIgor().close();
            } catch (SQLException ex1) {
                Logger.getLogger(ThreadMajProduits.class.getName()).log(Level.SEVERE, null, ex1);
            }
            break;
        }
    }
}
それが私が望むことを行う正しい方法であるかどうか、そしてこのスレッドがデータベースに接続しようとすることによって私のアプリケーションをブロックするリスクがないかどうか疑問に思っていましたか?
ありがとう