This is a discussion on mysql performance within the MySQL Database forums, part of the Database Forums category; Hi All, I develop an application in java in that several objects are querying a database, occasionally simultaneous. I think ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi All,
I develop an application in java in that several objects are querying a database, occasionally simultaneous. I think when this happens, the mysql server returns with an error message to one of this objects. My question is: what is the best practice when competeing objects are using the same resource? I was thinking on using table locks, but I am not sure whether it is the most elegant way to solve it. Any good experiences, ideas? Best, korcs |
|
|||
|
korcs wrote:
> Hi All, > > I develop an application in java in that several objects are querying > a database, occasionally simultaneous. > > I think when this happens, the mysql server returns with an error > message to one of this objects. > > My question is: what is the best practice when competeing objects are > using the same resource? > > I was thinking on using table locks, but I am not sure whether it is > the most elegant way to solve it. > > Any good experiences, ideas? > > Best, > > korcs > What kind of error are you getting? What do you mean by competing objects are "using the same resource"? That is, what resource? MySQL handles concurrent requests quite well. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
>I develop an application in java in that several objects are querying
>a database, occasionally simultaneous. >I think when this happens, the mysql server returns with an error >message to one of this objects. The normal MySQL response to two requests that conflict is to make one wait, so they happen as though one came after the other. If, for example, you are trying with two different requests to insert a record with the same primary key, and that is causing an error, you are computing a new primary key wrong (try an auto-increment column). If you THINK there is an error message, try actually logging it, along with the query that caused it and perhaps a time stamp. >My question is: what is the best practice when competeing objects are >using the same resource? What resource? A table? >I was thinking on using table locks, but I am not sure whether it is >the most elegant way to solve it. If you have a series of changes that need to be made all-or-nothing without interference from something else, use transactions (and InnoDB tables). |
![]() |
| Thread Tools | |
| Display Modes | |
|
|