oracle - How to synchronize a java method called by PL/SQL -
i have problem relative concurrency logic flow when client (called oracle forms) submit request (called concurrent programme ) , phone call plsql procedure, procedure phone call java static method.
what find when submit 2 request in same time or in short interval(like 1 second), concurrency problem noticed.
the java method start point of doing search database suggest records should inserted database.
the problem that, result in duplicated result since when query, both request find fine insert new records.
i tried add together synchronized in static java method, not solve problem, why?
what is:
class="lang-java prettyprint-override">public static synchronized void execute please note insert called in plsql, means not sufficient synchronize if synchronize java method. when log, shows 2 request run in same second, not think normal! since query database , doing suggestion time consuming.
to create java method time consuming, add together code phone call thread.sleep(5000), , log time after code , log thread id.
surprise see thread id 1! , also, time pass sleep in same time. why that?
what can solve problem? lock on java method or pl sql?
ps: trying utilize dmbs_lock, , seems working still hope know reason why java method not synchronized.
i have no thought how jvm within oracle db implemented, since (at to the lowest degree in mutual configurations) every database connection gets own server process, if separate jvm embedded each of those, synchronized block won't much good. you'd need utilize database locks.
java oracle concurrency plsql oracleforms
No comments:
Post a Comment