Solace
Solace

Reputation: 9020

JDBC and MySQL: Do changes in the underlying database are known to the java program?

Suppose that, after I establish a connection of my java application with my underlying MySQL database, and then open MySQL workbench and update some rows in a table, and then retrieve the fields of that table in the java client, will those changes synchronize with the java program. In other words, will those changes appear in the results of queries I carry out in the java program?

In general, after establishing a connection between a java application and a MySQL database, are the updates, deletions, alterations etc. carried out in the database by using the MySQL DBMS (and not the java program) visible to the program?

Upvotes: 0

Views: 112

Answers (2)

sandymatt
sandymatt

Reputation: 5612

Only if you run your query again.

Specifically, if you run something like this:

ResultSet resultSet = myStatement.executeQuery("select * from some_table");

and then you update the database (either from the command line / database client), then no. you will need to run your query again to see the changes you made.

Upvotes: 1

DaveH
DaveH

Reputation: 7335

In general, yes.

If they are not showing up, my first guess would be that you are not commiting the updates in the workbench

Upvotes: 2

Related Questions