ed0
ed0

Reputation: 49

Multithreading on a database using oracle and mysql

Does anyone have a code sample of a multithreading case that has about 25 threads that monitor a specific table in the database for a change then execute a process based on that change?

Upvotes: 1

Views: 238

Answers (3)

user330315
user330315

Reputation:

If you just want to be notified in the client application that something has changed in the database and you need to react on that in the application itself (so that triggers are not an option) you can use Oracle's change notification.

In order to do that, you register a listener with the JDBC driver specifying the "result set" that should be monitored. That listener will be called whenever something changes in the database.

For details on how this works, see the manual:

http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/dbmgmnt.htm#CHDEJECF

Upvotes: 1

Suraj Chandran
Suraj Chandran

Reputation: 24791

Try directly using a Database Trigger instead.

Check this question about getting events in java from Database

Upvotes: 0

mohdajami
mohdajami

Reputation: 9680

If you want to monitor the table (in the database) and make changes also in the database, then you should really consider Triggers.

Simply, Triggers are kind of procedures that run automatically BEFORE or AFTER changes on a table. You can monitor UPDATE, INSERT or DELETE transactions and then make your action.

Here is Simple tutorial on Oracle Triggers

Upvotes: 0

Related Questions