deep question on threadlocal with connection

J

John_Woo

Hi,

I'm wondering, if using threadlocal to *copy* a connection (connect to
mysql, with default setting), let's say now we have con1,con2,con3,...

con1 set isolation level to read-uncommit,
con2 un-repeatable,
con3 uses default setting,

questions:
1. how to know the con's life time or set it keep alive?
2. need to close all these cons once transaction done?
3. if con3 uses preparestatement to update a record which con1 just
changed, then before con3 commits, con1 rollback, how con3 knows and
taking no changing?
 
R

Rhino

John_Woo said:
Hi,

I'm wondering, if using threadlocal to *copy* a connection (connect to
mysql, with default setting), let's say now we have con1,con2,con3,...

con1 set isolation level to read-uncommit,
con2 un-repeatable,
con3 uses default setting,

questions:
1. how to know the con's life time or set it keep alive?
2. need to close all these cons once transaction done?
3. if con3 uses preparestatement to update a record which con1 just
changed, then before con3 commits, con1 rollback, how con3 knows and
taking no changing?

I think you're going to find that the database is the one that decides what
operations to permit and what operations to deny, not the JVM or the
connection manager or the JDBC driver.

I'm not very familiar with the internal workings of MySQL but I am familiar
with DB2 and have seen a lot of similarities between the two databases so I
suspect the two will behave similarly.

In DB2, it is the lock manager that makes the primary decisions about
whether to allow the actions of one connection to proceed when it conflicts
with the actions that another connection wants to take. Normally, older
connections are given priority over newer connections, i.e. things proceed
in a first-come first-served basis. If two or more connections can access
the same resource (table, index, etc.) at the same time without getting in
one another's way, this is permitted. If one connection will conflict with
another, the newer of the two connections is generally made to wait until
the older connection has finished its work and committed it, then the newer
connection can proceed. If the older connection does not commit quickly
enough, the newer connection will usually time out, i.e. it will receive a
return code that indicates it could not proceed because another connection
held a lock beyond the timeout interval.

But, again, I don't know if MySQL behaves quite the same as DB2. I think you
will find that it is best to ask your question on the MySQL mailing list
since the question has a lot more to do with MySQL than with Java. You can
subscribe to the MySQL mailing list at http://lists.mysql.com/. I think your
question belongs on the MySQL General Discussion mailing list, which is
quite active.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top