Please tell me, I want to implement reading the database table while the thread is running, what are the ways to implement this, and is it possible at all?
I give an example:
While the program is running, it reads the field of the database table and saves them to a separate file, when adding values to the field, it automatically saves this value to the file if the thread is running.
What did i get:
@Override
public void run() {
try {
Lock lock = new ReentrantLock();
lock.lock();
ResultSet resultSet = connection.createStatement().executeQuery("SELECT * FROM panel");
while (resultSet.next())
System.out.println(resultSet.getString("id"));
lock.newCondition().await();
} catch (SQLException | InterruptedException exception) {
throw new RuntimeException(exception);
}
}