Larry
Larry

Reputation: 11949

Postgres DB Trigger calling Java Function

Is it possible to define a trigger in a postgres DB that can call some Java function?

(I believe the above is possible in Oracle, but want to know if it for postgres).

So if this is possible, does this mean that the Java function would be called for every client application that is connected to the DB which of course has the function defined?

Thnx.

Upvotes: 2

Views: 8241

Answers (2)

Jihed Amine
Jihed Amine

Reputation: 2208

I don't know if it can fit your needs, but if you're using Hibernate to communicate with the DB, you can use Hibernate event listeners as triggers ( http://docs.jboss.org/hibernate/core/3.3/reference/en/html/events.html , http://docs.jboss.org/hibernate/core/3.3/api/org/hibernate/event/package-summary.html). That way it would work whatever the DB is (given you use standard SQL queries or HQL queries in the triggers)

Upvotes: 1

mu is too short
mu is too short

Reputation: 434975

There is the PL/Java add-on:

PL/Java is a free add-on module that brings Java™ Stored Procedures, Triggers, and Functions to the PostgreSQL™ backend via the standard JDBC interface.

I haven't used it so I can't comment on how good it is.

Upvotes: 1

Related Questions