Eduardo,
That is the way.
However Torque has wrapper class to do this stuff:
org.apache.torque.util.Transaction
with methods like:
- public static Connection begin(String dbName) throws TorqueException
- public static void commit(Connection con) throws TorqueException
- public static void rollback(Connection con) throws TorqueException
Hope this help
Edgar
----- Original Message -----
From: "Eduardo Albuquerque" <[EMAIL PROTECTED]>
To: "Turbine Users List (E-mail)" <[EMAIL PROTECTED]>
Sent: Friday, June 27, 2003 5:45 PM
Subject: Transaction Control
Hi folks,
Me again... :)
I'm looking for any reference in Torque documentation about the transaction
control and I didn't found anything... To control the integrit of a
transaction I'm doing the code above. Thats the best way? Do you have any
other ideas, tutorials, PDF's, ... ?
try {
Torque.init("Torque.properties");
con = Torque.getConnection();
con.setAutoCommit(false);
Publisher ediouro = new Publisher();
ediouro.setName("Ediouro Livros S/A");
ediouro.save(con);
Author tolkien = new Author();
tolkien.setFirstName("JRR");
tolkien.setLastName("Tolkien");
tolkien.save(con);
Book lotr1 = new Book();
lotr1.setTitle("Lord of The Rings - The Return of The King");
lotr1.setISBN("0-618-12902-2");
lotr1.setPublisher(ediouro);
lotr1.setAuthor(tolkien);
lotr1.save(con);
con.commit();
} catch (Exception e) {
try {
if (con != null || !con.isClosed()) {
con.rollback();
}
} catch (Exception ex) {
}
System.out.println(e.getMessage());
}
}
Thanks,
Eduardo Torres de Albuquerque
Desenvolvimento Web
Tools Software
Financeiramente, sua melhor ferramenta
Tel: 2533-1802
Esta mensagem pode conter informa��o confidencial e/ou privilegiada. Se voc�
n�o for o destinat�rio ou a pessoa autorizada a receber esta mensagem, n�o
poder� usar, copiar ou divulgar as informa��es nela contidas ou tomar
qualquer a��o baseada nessas informa��es. Se voc� recebeu esta mensagem por
engano, por favor avise imediatamente o remetente, respondendo o e-mail e em
seguida apague-o. Agradecemos sua coopera��o.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]