1

I am trying to execute my java application once a record is inserted, deleted or update into a database table. For that sake, I am planning to write a Trigger which will be called while inserting. My question is that, will I be able to call a java application from this trigger?

2
  • I don't think that is possible. Try different approach - eg. java app listens to changes on db and does required work if specific event appears. Commented Jun 23, 2018 at 18:47
  • java app listens to a particular record is inserted/modified/deleted in a table of a database? Commented Jun 23, 2018 at 19:02

1 Answer 1

4

While Python and Perl, among others, have a PL equivalent that can be written within an SQL function (albeit with sometimes considerable overhead), Java does not. Even if the Java app could be launched via command line or something after a trigger, the overhead in launching the JVM alone would be a performance disaster.

I would recommend looking into having Postgres emit notifications via notify. This would let you send a payload (although there are size limitations) that can be listened for by a client (that client could be your Java app, or an intermediate program that performed some additional ETL to get it ready for your app). This should allow for the data to be served up and processed in a performant way.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.