Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2005

Tip: Looking for answers? Try searching our database.

a JDBC question

Thread view: 
Jerry - 01 Aug 2005 21:40 GMT
In my code, I want to the following two queries as a trasaction. If any
of the two queries failed, the database will roll back both queries.How
to make two queries as one trasaction?

// will the code below regard query1 and query2 as trasaction?

query1 = "delete from table1";
query2 = "insert into table1 values ("a1, "a2);

statement1.executeQuery(query1);
statement1.executeQuery(query2);

conn.commit();

// If I don't issue a commit() explictly, will the above two queries be
commited automatically?

Thanks a lot!
Thomas Fritsch - 02 Aug 2005 01:07 GMT
> In my code, I want to the following two queries as a trasaction. If any
> of the two queries failed, the database will roll back both queries.How
[quoted text clipped - 14 lines]
>
> Thanks a lot!

What about reading the javadoc of java.sql.Connection?
Look at   setAutoCommit(boolean)

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

steve - 08 Aug 2005 23:35 GMT
> In my code, I want to the following two queries as a trasaction. If any
> of the two queries failed, the database will roll back both queries.How
[quoted text clipped - 14 lines]
>
> Thanks a lot!

FFS
Connection.autoCommit(false);

read it , understand it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.