Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

deep question on threadlocal with connection

Thread view: 
John_Woo - 12 May 2006 11:58 GMT
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?

--
Thanks
John
Toronto
Rhino - 12 May 2006 14:29 GMT
> Hi,
>
[quoted text clipped - 11 lines]
> 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.

--
Rhino
John_Woo - 12 May 2006 18:19 GMT
Thanks lots,  Rhino. It's been helpful.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.