Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Struts - Writing to a database

  • 24-07-2006 12:16PM
    #1
    Registered Users, Registered Users 2 Posts: 2,485 ✭✭✭


    Am just starting my first web app using struts and I have a question about writing data to database...

    I want to develop an application for entering data on forms.

    As a starting point I am following an example from here... http://www.coreservlets.com/Apache-Struts-Tutorial/

    It takes in data on a jsp page, stores it in a bean and then displays results back to the user. The data stored in the bean never gets written to a database. I would like to be able to write data stored in the bean (or taken from the form) to an sql server database. I have seen briefly how to set up a datasource in the struts-config.xml but how do I write to this datasource from my code (presumably from the Action java class?)

    Should I be using DAO? Never really used this before either...

    Any help appreciated guys....


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    If you havent done any database related stuff yet i.e. jdbc etc.. then I suggest you read up on that first. Once you know how to use jdbc, its as simple as calling getConnection() on the datasource to obtain your database connection and reading / writing your data to the db.


  • Registered Users, Registered Users 2 Posts: 2,485 ✭✭✭trotter_inc


    lynchie wrote:
    If you havent done any database related stuff yet i.e. jdbc etc.. then I suggest you read up on that first. Once you know how to use jdbc, its as simple as calling getConnection() on the datasource to obtain your database connection and reading / writing your data to the db.

    I know JDBC and how to get the connection, but Ive never used DAO and a lot of resources I've looked at suggests using it...

    I just want to make sure Im going in the right direction with it...


Advertisement