• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Code hangs on a preparesStatement insert

 
Ranch Hand
Posts: 681
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic