This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing data into sql database

 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have managed to get the information from the through beans in a jsf page1 and displaying them succeffully in the next page2 after clicking on a button page1.

Now my next objective is to write those details into a sql database. How do I proceed?
In the first page when the user clicks the button, then all the info should be written into a sql table. Please guide me. Thanks.

Regards
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18272
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the user clicks a JSF commandButton or commandLink, the backing bean's action method is invoked (after all the form properties, if any have been set). This is where you'd put the logic that writes the data to the database.

Exactly how to write to the database - basic JDBC, an ORM framework such as Hibernate, or whatever - is up to you.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim.
 
Gopu Akraju
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I van write a method inside java class to update the database. But where do I store tha database details? I tried as below. But I get some error in web.xml file.

web.xml as below:


I created context.xml to store the details of database as below:




I am following an example from web to apply into my application. Hence something is missing which I am nto aware. I get error as "Invalid content was found starting with the element <resoure-ref>.

My web.xml is as below:



Can anyone tell me how to proceed further? Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic