Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transaction

Status
Not open for further replies.

WebGoat

MIS
Jul 16, 2005
85
US
in my JSP page i when i do any DB operation i start with
Code:
setAutoCommit(false);


try
{
//SQL Query here
//

commit();
}catch(Exception e) {  // rollback() here if there is some exception }

is this called transaction ?
 
hi, i am not clear yet. the dictionary link is telling this

A simple transaction is usually issued to the database system in a language like SQL in this form:

1. Begin the transaction
2. Execute several queries (although any updates to the database aren't actually visible to the outside world yet)
3. Commit the transaction (updates become visible if the transaction is successful)

If one of queries fails the database system may rollback either the entire transaction or just the failed query. This behaviour is dependent on the DBMS in use and how it is set up. The transaction can also be rolled back manually at any time before the commit.


look at my code. have not i done the same thing ? in fact i write code that way . so i always feel that is called the trasaction because the code has commit and rollback. .
and i believe if a code has commit and rollback that is a transaction. am i wrong ?
 
A transaction is just an operation performed between two agents.

So a java based client executing a SQL statement against a database is a transaction.

Purchasing a book from a bookstore is a transaction.

A conversation could be said to be a transaction.

The link provided by Dian describes a SQL transaction.
Your code that you posted is a transaction.

Yay !

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I thought the link would be quite illustrative.

Anyway, in other words, a transaction uses to be most times an indivisible set of actions. In the DB world, it involves a set of queries that are executed all or none.

Nevertheless, the word itself can have other meanings and you can see it in a lof of contexts: transaccional monitor, transactional conversation and so on.

Cheers,
Dian
 
thanks for the answer . sedj, and dian can you people tell whether there are more things to learn about transaction in terms of coding apart from commit() and rollback()? i have not found yet.

i dont know whether i have learnt all about transaction or not. when i ask any people they say "Ohh, transaction is a very very big chapter , and EJB developers uses that ". From this comment i started believing that i know nothing about transaction. and transaction things are exclusive only for the EJB developers. may be EJB developers dont use commit() and rollback() like me, they might be using some other advanced things which will be called pure trasaction laws.

 
Transactions is more a concept than a practice. You can know what a transaction is, the concept itself is pretty simple.

But in the real world there are an obscene number of transaction examples: banking transactions, commercial transaccions.

The software world just mirrors the real one, and in almost every system or language you will find the concept and implementation of transaction.

The commit-rollback thingie is just a way to do it. There are plenty. Maybe you should first clarify about what do you really want to learn.

Cheers,
Dian
 
As Dian says, a transaction is a concept.

I'll do you a deal, if you tell me 5 transactions in the real world, and how they are implemented, including verbal, and non-verbal transaction bases, I'll give you a detailed description of what a SQL transaction looks like, and what an EJB transacftion looks like. Heck, I'll even throw in an SMTP transaction, and an HTTP transaction.

Looking forward to your descriptions ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
OK,

i was talking about banking transaction . is not it safe with just commit() and rollback for banking transaction ?

How developer write code for transaction in internet banking ? does there huge code involved ? do i need to depend on third party ? i noticed some website use "Verisign Protected" stamp while you are going for transaction with credit card .

might be Verisign guys do some encryption so that other intruders can not snatch your number from the internet (its funny ).

However, how does a banking tranasction looks like ?


when i ask any people they say, transaction is a very very difficult thing. i only know, if all the data are going to all tables then thats a commit() otherwise if one of them fails , i do the rollback. thats what i know only.
 
I think your question is a little vague, you've been going from pure SQL to banking transactions.

Maybe if you tell us what do you want to know exactly, and supposing it has something to do with Java, we can help you.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top