• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Storing form data in a database

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
I've a HTML form say,Feedback.html.I need to retrieve values from it and store it in the database table.I ve got FeedbackServlet.java which shd be doing this.I am storing the values in the vector.
But the problem is,The order of columns changes for every Submit.So i can not store as is it in a table.What do i do??and How??
Shd I ve a 2 dimensional vector and get column names & values dynamically??(i tried this but failed)
Can nayone help me with this or suggest smthg better
Thanxx
SWati
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I donot understand what is
"The order of columns changes for every Submit."
If you give some more details with code, may I may able to help.
solaiappan
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi swati
its pretty simple don't go for vector..since the fields in the feedback form is defined(say 10 fields)..go for an array then store values from the field seperated by a delimiter | sign.you can use a string tokenizer to retrieve the values and store it in database and also you can store the values as per you sorting which will not give you the problem as you mentioned earlier in vector
all the best
ram
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by P SOLAIAPPAN:
Hi,
I donot understand what is
"The order of columns changes for every Submit."
If you give some more details with code, may I may able to help.
solaiappan


Hello, What I mean by this is..
Say ,I ve 9 fields in my form and have corresponding database columns in my Table Feedback_Master_T.Feedbackform has fields namely Username,Email,Fax,TEl,Comments etc.So when user clicks on submit ,the order in which the values shd get insert into the table is Username,email,Fax,Tel,Comments.
But this order is getting changed for EVERY SUBMit and so I am having problem inserting it into the database.In mytable I get name in Fax column and so on.
Is it clear now??
So I need to retrieve field names & values dynamically and accordingly write the insert statement
Will u be bale to help me now??
Thanx
Swati

 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is always good procedure to use the full form (with column names) of a SQL insert statement, so that which columns you are inserting are tied to the values. It is also good practice to extract servlet parameters by name too, so you should be able to avaoid this problem.
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Frank Carver:
It is always good procedure to use the full form (with column names) of a SQL insert statement, so that which columns you are inserting are tied to the values. It is also good practice to extract servlet parameters by name too, so you should be able to avaoid this problem.


Thankx
It did work properly.All my problems are solved
Swati
 
reply
    Bookmark Topic Watch Topic
  • New Topic