2uzhan.com
Advertisement
Now Place:2uzhan.com » insert data from one form into two diffent database table

insert data from one form into two diffent database table

Web Development @ February 27, 2007   Views:0

Hi Experts,

I have a small problem in my Projects. I need to insert the registration data into two differnt database table.I am using jsp code to do that opration. Pls Tell me some way in which i can ful fill this requirment.

Should i use two differnt connection,Resultset , Statement for each or any other way ...Pls suggest if any....

-Jeet

--------------Solutions-------------

you don't want to do that (at least not in JSP).
You want to use a servlet for that.
You also want to read a beginner's tutorial on JDBC.
You want to learn something about databases too.

Well, you can certainly do it by embedding some Java code in your JSP file...
Instead of trying to insert it directly from JSP tags...or a custom tag library...

You can create a custom tag library to handle this also... but it is basically handled by setting the DB Connection object to disable auot comit if insert and updates...

I use PostgreSQL 8.2 so I use conn.setAutoComit(false);
Then you insert the first and check if it worked... use conn.rollback(); if it failed and exit with and error code or message or whatever... if it worked insert the other part of the data to another table... chekc that it succeeded, and if not do the same as above...using conn.rollback(); that undoes both inserts if the second one fails... if the second succeeds then you can do conn.comit();
conn.setAutoComit(true);
and you're done...

many people set both, and check if they both suceed, then do the rollback or comit logic once.... BUT since DB transactions are more overhead than checking success... check after EACH and stop the transaction and roll it back upon the first failure...so you don't waste time with SQL inserts that will just get rolled back since an error already happened....

I set my auto comit back to true just completeness each time... but it doesn't really matter unless you are using static connections.... which you should be doing if you have a busy site...

Peace,

When a user enters the page in question, a textarea is populated from data from a text file stored on the server. The user can then edit that text (add, ...

I'm attempting to simplify my fundraising page, and would like to show exactly how much each donation would help us out. I've listed the options below, but I would like ...

I have a list.php which displays all the records that is in the database with 2 options Edit or Delete. When clicked its suppose to delete by id but instead ...

Tags:jsp
© 2018 2uzhan.com Contact