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 2006

Tip: Looking for answers? Try searching our database.

Simple question about an insert query...

Thread view: 
gbattine - 22 Aug 2006 11:16 GMT
excume me guys,
i've a problem and i need your help.
I'm developing a jsf application.
I've 2 mysql tables

experiment(id_exp(autoincremented), name, author)
sample(id_sample(autoincremented),id_exp,value)

My application performs inserting into the 2 table.
My question is:
when i do insert in experiment in my query i don't use id_exp attribute
because it's autoincremented and everythings go well.

Later i've to insert more samples entities in sample table relating to
the same experiment inserted,that is i've more samples for the same
experiment.
What have i pass in my insert query on sample for id_exp to reference
the experiment autoincremented id before inserted?
I have to do everythings in one transaction(the 2 insert queries)..
can you help me?
Thanks very much
Moiristo - 22 Aug 2006 11:41 GMT
> excume me guys,
> i've a problem and i need your help.
[quoted text clipped - 16 lines]
> I have to do everythings in one transaction(the 2 insert queries)..
> can you help me?

I have about the same question. Consider a transaction where the first
insert statement creates an ID that I need for two other queries in the
same transaction. How can this be done? When I just create a transaction
(autocommit false), a deadlock occurs. I'm using j2ee with the latest
mysql connector on mysql5.
Thomas Kellerer - 22 Aug 2006 12:12 GMT
> excume me guys,
> i've a problem and i need your help.
[quoted text clipped - 17 lines]
> can you help me?
> Thanks very much

getGeneratedKeys() should return the generated IDs:

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Statement.html#getGeneratedKeys()

Thomas

Signature

It's not a RootKit - it's a Sony



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.