Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Struts - Writing to a database

Options
  • 24-07-2006 12:16pm
    #1
    Registered Users Posts: 2,492 ✭✭✭


    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 Posts: 1,996 ✭✭✭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 Posts: 2,492 ✭✭✭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