You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Alain Pilon <al...@hec.ca> on 2004/04/20 18:00:06 UTC

managing connetion

Hi all!

I would like to know how Torque manage connections. I know that I can change
the connection pool but so far, I want to stay with the one provided. So
here is my question: Does Torque uses a distinct connection every time I use
the .save() methode or he waits a moment to see if there are more requests
comming before executing the connection?

I am writing some TestCase right now where I have to insert about 10 record
in a table. They all have the same inserted date. Unless I am mistaken, the
only possible way that they all have the same value is if they are inserted
at the exact same time with the same connection, right?

Thanks!

Alain Pilon
Analyste - Traitement de l'information budgétaire
HEC Montréal


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


schema.xml and databaseName

Posted by Alexandru Dovlecel <al...@siemens.com>.
Hi all,

I have a problem and I don't know what to do. I have set in my x-schema.xml
the databaseName='x'.

But in my runtime configuration file I have the database renamed from 'x' to
'myx'. When trying to run the program I get strange NullPointerException.
Why? (e.g. myobj.save( "myx" ) ;

1) If I change the runtime configuration file and I have the database name
as 'x', all works fine. (also changing the myobj.save( "myx" ) to
myobj.save( "x" )

2) If I change the schema file with databaseName="myx" and I regenerate the
files with ant, it works fine.

So... this is really strange. It should not happen, because in this case, I
always have to match the name in the schema.xml file with the name in the
runtime configuration file. So if I need a different runtime config DBName,
then I have to recreate the files??? C'mon... am I doing something wrong???

And also, I can't reuse the generated classes to access two databases, even
though they have exactly the same structure, because they will have two
DBNames in the runtime config file. This is quite a nasty problem (IMHO).

Can somebody tell me how to overcome this situation?

10q
Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: managing connetion

Posted by Kostyantyn Shchekotykhin <ko...@ifit.uni-klu.ac.at>.
Hi All!

Scott Eade wrote:

>> 
> See the answer to question 10 in the Torque FAQ: 
> http://wiki.apache.org/db-torque/FrequentlyAskedQuestions#head-f21b65aabdf5f90c9f5df248411b7de3aab118b7
> 
i'm not sure if Thomas Fischer if right writing:
"Note that Transaction.safeRollback() does not release the database connection, so replacing Transaction.rollback() by
transaction.safeRollback() in the above code would lead to the leakage of database connections if the transaction fails."
here is the safeRollback method

     public static void safeRollback(Connection con)
     {
         if (con == null)
         {
             log.debug("called safeRollback with null argument");
         }
         else
         {
             try
             {
                 Transaction.rollback(con);
             }
             catch (TorqueException e)
             {
                 log.warn("An error occured during rollback.", e);
             }
         }
     }
as you can see it is doing the same as Thomas Fischer wrote in example. So IMHO users can freely use safeRollback if 
they do not need rollback exception handling.

Regards,
Kostya

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: managing connetion

Posted by Scott Eade <se...@backstagetech.com.au>.
Alain Pilon wrote:

>I would like to know how Torque manage connections. I know that I can change
>the connection pool but so far, I want to stay with the one provided. So
>here is my question: Does Torque uses a distinct connection every time I use
>the .save() methode or he waits a moment to see if there are more requests
>comming before executing the connection?
>
>I am writing some TestCase right now where I have to insert about 10 record
>in a table. They all have the same inserted date. Unless I am mistaken, the
>only possible way that they all have the same value is if they are inserted
>at the exact same time with the same connection, right?
>  
>
See the answer to question 10 in the Torque FAQ:
http://wiki.apache.org/db-torque/FrequentlyAskedQuestions#head-f21b65aabdf5f90c9f5df248411b7de3aab118b7

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org