How to implement pushing data from database to user?
How to implement pushing data from database to user?# Java - 爪哇娇娃
p*u
1 楼
帖一首老歌,让大家“想入非非”在梦里呼呼吧~~ xixi..
c*o
2 楼
How to implement this in JAVA? Does any body know in oracle database, if data is changed, how to java system get informed then sent notify to client? I thought database trigger can monitor the data changes, but it can not inform java system, right?
Depends on how real time it is needed. Usually you can use a java thread to check certain DB field periodly (poll) to notice the change.
【在 c**o 的大作中提到】 : How to implement this in JAVA? : Does any body know in oracle database, if data is changed, how to java : system get informed then sent notify to client? : I thought database trigger can monitor the data changes, but it can not : inform java system, right?
x*n
5 楼
吼吼
c*o
6 楼
I think this way should not be very efficient, since the thread runs all the time, and in every checkup the thread should make a query, right?
【在 g*****g 的大作中提到】 : Depends on how real time it is needed. Usually you can use a java thread : to check certain DB field periodly (poll) to notice the change.
g*g
7 楼
A sql query usually takes less time than you'd think. It's going to be ms level. I'd say this is sufficient for most projects. You don't worry about performance until performance is a problem.
the
【在 c**o 的大作中提到】 : I think this way should not be very efficient, since the thread runs all the : time, and in every checkup the thread should make a query, right?
c*t
8 楼
1. there is no way to do it with pushing. 2. pushing (in general) is nearly always a bad idea (in terms of performance etc).
the
【在 c**o 的大作中提到】 : I think this way should not be very efficient, since the thread runs all the : time, and in every checkup the thread should make a query, right?
c*o
9 楼
Can you give me a hint why you pick up thread, not a simple loop? the two ways look like the same to me. And for real implement, thread is much more difficult to deal with than loop.
【在 g*****g 的大作中提到】 : A sql query usually takes less time than you'd think. It's going to be : ms level. I'd say this is sufficient for most projects. You don't worry : about performance until performance is a problem. : : the
g*g
10 楼
Usually you don't want to lock up the main application, if that's not a problem, go ahead and do whatever is simple for you.
【在 c**o 的大作中提到】 : Can you give me a hint why you pick up thread, not a simple loop? : the two ways look like the same to me. And for real implement, thread is : much more difficult to deal with than loop.
s*d
11 楼
polling by querying is not a bad idea if the query is not that complex and time consuming. if you are using oracle 11g, you may also consider a new feature called Database Change Notification. Basically you can register a query in Java to the JDBC layer, and database will notify it when the result set of the query changes. http://www.oracle.com/technology/obe/hol08/11gR1_JDBC_Java/dcn_otn.htm another possibility (if you need near-real time alerts), might be to use triggers and make an HTTP POST
c*o
12 楼
Thanks, it helps. But I don't know how to make an http post call inside the trigger.It is new feature in oracle 10g? or 11g? Can you give me a simple example.
to query
【在 s****d 的大作中提到】 : polling by querying is not a bad idea if the query is not that complex and : time consuming. : if you are using oracle 11g, you may also consider a new feature called : Database Change Notification. Basically you can register a query in Java to : the JDBC layer, and database will notify it when the result set of the query : changes. http://www.oracle.com/technology/obe/hol08/11gR1_JDBC_Java/dcn_otn.htm : another possibility (if you need near-real time alerts), might be to use : triggers and make an HTTP POST
c*o
13 楼
for the first, I don't know, I am trying to find out here. The second, Why? it supposes to be efficient than pulling, right?
performance
【在 c*****t 的大作中提到】 : 1. there is no way to do it with pushing. : 2. pushing (in general) is nearly always a bad idea (in terms of performance : etc). : : the
c*o
14 楼
Thanks, make sense.
【在 g*****g 的大作中提到】 : Usually you don't want to lock up the main application, if that's : not a problem, go ahead and do whatever is simple for you.
s*n
15 楼
who changed the data?
【在 c**o 的大作中提到】 : How to implement this in JAVA? : Does any body know in oracle database, if data is changed, how to java : system get informed then sent notify to client? : I thought database trigger can monitor the data changes, but it can not : inform java system, right?
s*e
16 楼
Oracle has built-in java support. You might be able to take advantage of it. sleeping and poll can be an idea, but for me a more elegant way is using MOM such as JMS message broker.
【在 s******e 的大作中提到】 : Oracle has built-in java support. You might be able to take advantage of it. : sleeping and poll can be an idea, but for me a more elegant way is using : MOM such as JMS message broker.
s*d
18 楼
you should look up the PL/SQL package called utl_http which can be used to send http requests.
the
【在 c**o 的大作中提到】 : Thanks, it helps. But I don't know how to make an http post call inside the : trigger.It is new feature in oracle 10g? or 11g? Can you give me a simple : example. : : to : query