18 messages in com.mysql.lists.javaRe: transactions no longer being comm...| From | Sent On | Attachments |
|---|---|---|
| Jeff Mathis | 22 Jul 2003 15:25 | |
| Jeff Mathis | 22 Jul 2003 15:35 | |
| Mark Matthews | 22 Jul 2003 17:45 | |
| Rakesh Ayilliath | 23 Jul 2003 06:01 | |
| Shapiro, David | 23 Jul 2003 06:14 | |
| Jeff Mathis | 23 Jul 2003 08:24 | |
| Rakesh Ayilliath | 23 Jul 2003 08:25 | |
| Christopher Taylor | 23 Jul 2003 18:44 | |
| Jeff Mathis | 24 Jul 2003 08:20 | |
| Jeff Mathis | 24 Jul 2003 12:43 | |
| Jeff Mathis | 24 Jul 2003 13:25 | |
| Mark Matthews | 24 Jul 2003 14:05 | |
| Christopher Taylor | 24 Jul 2003 17:38 | |
| Jeff Mathis | 25 Jul 2003 08:41 | |
| Jeff Mathis | 25 Jul 2003 15:06 | |
| Jeff Mathis | 25 Jul 2003 15:12 | |
| Christopher Taylor | 25 Jul 2003 19:34 | |
| Jeff Mathis | 28 Jul 2003 07:51 |
| Subject: | Re: transactions no longer being committed![]() |
|---|---|
| From: | Jeff Mathis (jmat...@predict.com) |
| Date: | 07/25/2003 03:12:49 PM |
| List: | com.mysql.lists.java |
looks like the bottom of my message got chopped ---
From a design point of view, I was thinking that maybe my objects shouldn't have a reference to the Connection that created them. Then sharing them between Connections wouldn't be an issue. All objects implement Comparable, which uses the row id in a table and the table name for unique identification, so I don't think a database deadlock would come about. What do you think?
Jeff Mathis wrote:
Yes, it is a standalone application. I use multithreading to speed up data loading.
My schema is heirarchical. I have a few parent tables, and lots of child tables that refer to the parent tables via PK/FK constraints. My objects basically represent a row in a given table. For a child table, the constructors all take the parent object they are associated with, and then get their Connection object from that parent.
When I created separate threads (all in a ThreadGroup), each with their own Connection, I shared a set of parent objects loaded in the beginning of the application run from a Connection that was not in the new ThreadGroup. Hence, all child objects were referencing the parent objects Connection.
My data loader would then call commit() on the Connection belonging to an individual thread, which was not the correct one. I fixed the problem by adding a check in a central Store object, which holds a reference to the Connection, to make sure all objects in that Store have the right Connection. I'm using the mysql query "select connection_id()", which will return a unique connection id.
-- Jeff Mathis, Ph.D. 505-955-1434 The Prediction Company jmat...@predict.com 525 Camino de los Marquez, Ste 6 http://www.predict.com Santa Fe, NM 87505




