• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code hangs on a preparesStatement insert

 
Tony Evans
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am experiencing very weird behaviour. My Java Code is trying to perform a PreparedStatement.executeUpdate() performing a insert.

But when it get to the PreparedStatement.executeUpdate() it seems to hang on the insert, as if the table is locked.

As I understand it a insert does not lock a table.
The table does not seem to be locked as I can insert into the table using toad.

No SQL exception is thrown, so its not a data problem.

Has anyone ever experienced thisproblem before. I am using Oracle 9i.

Thanks Tony
 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out with the connections, Some times if you have problem with the connections it behaves weird. As you checked rest of all try to add a record through SQL Prompt with the same data, and try to print the query run time and execute the same thing in TOAD.

Hope this helps you,
Srilakshmi
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony,
First thing to check is whether TOAD itself has a lock on the table. That's happened to me quite a few times through sqlplus.

Also, can you show the query you are using. Maybe it is doing a lot of work?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony,
You said:

it seems to hang on the insert

Either it hangs, or it doesn't. What do you mean by "it seems to hang"?
You also said:

As I understand it a insert does not lock a table

Perhaps you misunderstand how Oracle handles locking issues. Have you read the chapter on "Data Concurrency and Consistency" in the Oracle "Database Concepts" guide -- which is part of the Oracle documentation, and available from:

http://tahiti.oracle.com

As Jeanne says, if you insert a row into a table -- in TOAD -- and don't commit, then you have placed a lock on [all or part of] that table.

You can check the "V$" dynamic views in Oracle to see the current status of database locks. See the Oracle "Database Reference" for more details.

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic