Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Writing data to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Writing data to database" Watch "Writing data to database" New topic
Author

Writing data to database

Mayura Hayat
Greenhorn

Joined: Dec 24, 2012
Posts: 11
Hello
i have a jsp page which takes in the details from the user like the name, age, gender,etc.
how do i insert data for more then 1 user into the database at the same time i.e just by a single click.???
i'm not using servlet.

please please help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Mayura Hayat wrote:how do i insert data for more then 1 user into the database at the same time i.e just by a single click.?

What do you mean by more than one user? How can more than one user be submitting data?

i'm not using servlet.

Why not? A servlet should be used to process the data.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mayura Hayat
Greenhorn

Joined: Dec 24, 2012
Posts: 11
i think i was not quiet clear when i posted the question.
well i'm doing a project on flight reservation. what i want to ask was that when the user login he is able to book ticket for more den 1 person.
so i have provided textboxes to add the relevant info. about more people i.e if he is to book two tickets he needs to enter the data i.e name age gender for two people.

At Backend(oracle 10g XE) i want to add this data to the database.. but unable to do it.

how do i acheive this on the single submit.???

please help..
Thank you in Advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39571
    
  27
What does "unable to do it" mean, exactly? What does your code currently do? And as Bear said, a servlet is the way to handle a form submission like this.


Ping & DNS - updated with new look and Ping home screen widget
Mayura Hayat
Greenhorn

Joined: Dec 24, 2012
Posts: 11
unable to do it means that i'm unable to add the data to database...
my code accepts the data or rather insert the data just for one person into the database ... but not for more then one person.
Yes taking his advice i'm using scriplets..

i'm new to jsp.

Any help will be useful. please.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39571
    
  27
I don't think we'll be able to give any more advice without seeing the relevant code excerpts (that get the data from the form submission and store it to the DB).
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60071
    
  65

Mayura Hayat wrote:
Yes taking his advice i'm using scriplets..

Who said anything about scriptlets? Scriptlets should not be used!

You should be submitting the form to a servlet.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2713
    
    5

Mayura Hayat wrote:insert the data just for one person into the database ... but not for more then one person.

If you are able to successfully insert one record, then one possible deduction I can make is that you are using request.getParameter() for reading multiple values.

SCJP, SCWCD.
|Asking Good Questions|
Mayura Hayat
Greenhorn

Joined: Dec 24, 2012
Posts: 11
Amit you are right.
m i doing it the wrong way.? can you tell me the correct way to do it?
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Could you show us your code snippet.


Swastik
Mayura Hayat
Greenhorn

Joined: Dec 24, 2012
Posts: 11
flightbook.jsp:


i'm new to jsp any suggestion will be taken.
Thank You in advance.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6



Is it not leading to ArrayIndexOutOfBoundsException?

Should it not be?

Mayura Hayat
Greenhorn

Joined: Dec 24, 2012
Posts: 11
hey thank you all especially swastik... it worked.. i was struggling with this thing for a long time.
data successfully entered into the database ... :) ohhh!! that's Christmas!!

Thank you once again all.
and i'm sorry for the inconvenience caused.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing data to database
 
Similar Threads
Data of previous form gets submitted on refersh
data mixup for two responses
Session or DB
How to pull data from database using JSP?
How to bind data to a textbox in servlet?