• 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

database best practice

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
Please tell me the best practice for store my form data persistently in my database.

I have one form for to track the user input i.e first name,last name and email id.when user fill and submit it will go for validation ,if entries are fine it goes to servelet,in that servlet i instantiate the bean and using setter methods of the bean i am storing the data temporarily upto now.

now my request is i want to store the form data in our database which is oracle8i, and if i want to retrieve later it is also recommended.so for this scenario how to write the code and where i need to write the code .writing the code in servlet is better or in separate bean.so which one is good and if possible give me sample code for better understanding.

thanks all in advance.

cheers,
babu.
[ January 19, 2006: Message edited by: Bear Bibeault ]
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
please extend the thread.

cheers,
babu.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is some suggestions..

Entity beans/session beans will be best if you are using EJBs..

If you are using JDBC, try to design some generic classes which can be reused..
you can have java beans or value objects for holding table data.
put all your queries into xml file so that db changes doesn't affect your code..
Have a seperate class to do all db operations..

Have a look at DAO pattern..

Regards,
Raja.
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi raj,
i am using only jdbc and i am willing to use normal javabean for to hold table data.please give any code sample for to achive it.

cheers,
babu.
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello all,
please extend the thread.please.

cheers,
babu.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by babu amara:
hello all,
please extend the thread.please.

cheers,
babu.



Babu,
Please read this:
http://faq.javaranch.com/view?PatienceIsAVirtue

Also, JavaRanch is not a code mill.
People here are happy to help you if you get stuck on something specific when working on your project but nobody here is going to hand you back a solution if all you can give us are your requirements.

What have you done so far?
What part are you stuck on?
[ January 20, 2006: Message edited by: Ben Souther ]
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
below is my view.jsp:
========================


below is my servlet:
====================


below is my bean:
==================

upto now i am keeping the data in bean for short period,now i want that form data in database.how i can achive.
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recommend you read into JDBC usage or an ORM framework like Hibernate. I personally prefer Hibernate as it leads to more structured and easily modifiable code. It is also database independent and that is quite a plus.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you familiar with JDBC?

If so, you could start by either, making that javaBean database capable (add methods that read and write to the database) or by creating another object who's job it is to read and write the fields from that bean to/from the database. Either way, start out by giving your objects main methods so you can perform the database operations from the command line.
Don't even try to work with these beans from the servlet app until you know the database methods work.

For the sake of simplicity, I would start out by loading the driver from within your database method using forName(drivername).
Once it's working and you're comforatable with that, I would look into the connection pooling mechanism provided by your servlet container.

If you're not familiar with JDBC, there are plenty of tutorials
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ben,
thanks for your advice.


Are you familiar with JDBC?



yes, i am familiar with JDBC.but only the problem is how and where i need to write the code to store the form data in database.please see the code in above reply.I loaded the oracle thin driver ,it is working fine.please initiate me to write the relevant code for to store the data in database.

The important point is
1.where i need to write the code 2.please give me code sample for to write my appliation specific code,plese see the code i posted above.


thank s in advance.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Babu",
You have 62 posts and an invalid display name. If you do not correct your display name your account will be closed.

We require display names to be two words: your first name, a space, then your last name. Fictitious anme are not allowed.

Please correct your display name immediately.

thanks,
Dave.
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

sorry single word name.I changed to two word name.

thanks .
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

thank s i got solution to store the form data in database.
thanks wonderful javaranchers.

cheers,
babu.
 
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic