I have a simple program that does database update using Oracle Driver. It is a long running sql that works in SQLDeveloper mode but hang on executing in Java program:
String sql = "UPDATE ...";
PreparedStatement ps = conn.prepareStatement(sql);
log.info(sql);
int affectedRows = ps.executeUpdate();
log.info("affected rows = " + affectedRows);
It logs the sql line, but never prints the affected rows line.
In the database it shows the execution (V$SESSION_LONGOPS
) is completed with 0 remaining time:
However weird thing is this session only exists in V$SESSION_LONGOPS
but not V$SESSION
. And apparently this never gets back to the Java program. In the running system of the program, ps -ef
gives this info:
user 5889 5885 0 00:00 ? 00:00:11 /java/jdk1.6.0_25/bin/java -cp ...
It shows it started running at 00.00 (scheduled by Cron) and only executed for 11 seconds (and now it is 10am which 10h has passed). It seems like the program just hangs/dies, and no exception is given in the log (a big try catch is surrounded with log exception).
It never reaches to the end of program because ps still prints this and there is no logs of the coming line.
Would appreciate any help that points to the direction.
You can check below tables whether your session is in waiting mode or not.
select * from dba_blockers; select * from dba_waiters;
Make sure your session is not in above query.
and also check whether your objects is not locked with below query
select * from v$locked_object in this view you can get locked object id and from dba_objects you are able to get object name.
if you found any session in this then please kill or finish that session first.
I had the same problem you had, I don't know about others but I solved it by simply closing SQLplus! I didn't think that could solve it since some queries worked while sqlplus was running on the console, but I closed it and now every queries work and nothing hangs!
You may want to try this if you have our problem!
I had the same problem. executeUpdate was just hanging and there was no error.
The problem: I was at the same time connected with sqlDeveloper to the same db and had the same table open. As soon as I disconnected sqlDeveloper from the DB, the statements could be inserted and the java application went on working fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With