Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Nitiraj
Starting Member
1 Post |
Posted - 2009-11-02 : 08:34:57
|
| Hi,I am using java Connection objects for making sql queries to ms-sql server.As far as I know there are two ways to make a transaction1. to make the Connections.autoCommit(false) and then commit only when all changes are successfully applied2. other is to make a stored-procedure and make a transaction in iteg. BEGIN TRANSACTION.... some sqlsCOMMIT TRANSo my questions are Q1 : What are the difference between these two types of transactionsQ2 : If I am executing a store procedure from a java program with Connection.setAutoCommit(false) and the stored procedure also contains the Transaction statements as above then which commit will actually get preference ? eg.String sql = "stored-procedure1" ; Connection con = new Connection() con.executeUpdate(sql)con.commit() ; // 1 con.close() ;where stored-procedure1 : ( something like )begin transactionupdate table1 set x = 10 where y = 14 commit tran // 2so the actual commit takes place at statement 1 in java program or at statement 2 in the sql stored-procedure ? -- nitiraj |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-11-02 : 13:19:00
|
| that is a good question. I would say test it out, also using SQL profiler and some other debugging tool on your java end and literally opening table while you have it paused on the java side of code.<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
|
|
|