如何使用java创建数据库监听器? [英] How to make a database listener with java?
问题描述
问候所有
我想做一些类似于触发器或侦听器(我不知道是什么)的东西,它们将在特定的数据库表上进行侦听,并且在此表上插入每条新记录,执行一些java代码,我的意思是它检测到插入了新记录,并且如果可能的话获取它的数据
我需要一些关于如何完成这个过程的指南?
我正在使用Spring-Hibernate-PostgreSQL
这就是 LISTEN / NOTIFY 已创建。
唯一的缺点是您需要有一些后台线程定期轮询数据库以查看是否有任何通知可用。
您也可以使用 Postgres Wiki 有一个出发点
Greetings all I want to do something like a trigger or a listener (I don't know what) that will listen on a specific database table, and with each new record inserted on this table, do some java code, I mean that it detects that a new record was inserted and get it's data if it's possible I need some guide about how this process can be accomplished ?
I am using Spring-Hibernate-PostgreSQL
This is what LISTEN/NOTIFY was created for.
The only drawback is that you will need to have some kind of background thread that polls the database on a regular basis to see if any notifications are available.
You can also use the code from the Postgres Wiki to have a starting point
这篇关于如何使用java创建数据库监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!