Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes A lot of deadlocks using JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "A lot of deadlocks using JDBC" Watch "A lot of deadlocks using JDBC" New topic
Author

A lot of deadlocks using JDBC

Andrei Antonescu
Ranch Hand

Joined: Jul 08, 2010
Posts: 75
Hello all,

I am using Sql Server 2008 for a web app deployed in Tomcat 6. There are a lot of simultaneous users that query the database. I get a lot of these errors in the tomcat logs:



Is it normal to be soo many of them? Can you tell me from where to start the investigation? Because I don't have a clue....

Thanks in advance
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Do you use "select ... for update"?
Do you keep transactions open for long time?
Do you use locking hints in your queries?
What is your connection's transaction isolation level? Have you specified it?


OCUP UML fundamental and ITIL foundation
youtube channel
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Do you use "select ... for update"?

SQL Server doesn't support his construct. But the question is still valid if you are using explicit locking hints. Are you?

In SQL server you can track why deadlock are occurring with the profiling tool. If you run your application and trace deadlock events with that you should get a picture of what sort of transactions are causing the deadlocks. Alternatively, if you can't use the profiling tool you can turn on trace logging for deadlock with dbcc. You could start by reading this.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Andrei Antonescu
Ranch Hand

Joined: Jul 08, 2010
Posts: 75
Hello & thanks for posting

I use the default isolation level, I don't keep the transactios open for a long time, and I don't use locking hints in my queryes.

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You need to find out what the profiling tool suggests is the cause of the deadlocks - this is not something we can know. There are common patterns of behaviour that can increase the likelihood of deadlock, but rather than go through these all I would start by using the tools SQL Server supplies to get more information.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A lot of deadlocks using JDBC
 
Similar Threads
JMS and JDBC In a single transaction
How to see tomcat process in linux
Transaction roll back while using Oracle XA driver
Data Access Object Pattern
background process on tomcat 4