views:

22

answers:

1

Unable to determine what is the best way to connect to mysql database in struts..

  1. We can always use DriverManger and Class.forName() to connect.
  2. DataSource interface - but this has problems I am getting compliation error for

    DataSource dataSource = (DataSource)context.getAttribute(Globals.DATA_SOURCE_KEY); or when Action.Data_SOURCE_KEY is used. when searched I found that these variables are depricated.

How can I use connection pooling in struts?What is best place to place url,username,pass for database?DO i still have to use datasource configuration in same way in struts-config? Then why was this facility depricated?

Too many queastions but I cannot find a definite source to learn struts. Struts doc can be but then revisions and backword compatibility are the issues which a learner cannot get easily... Pls suggest a good source to learn struts2.

+3  A: 

Struts is an MVC framework, not a database access framework. You should use some sort tool for your Data Access Layer. Spring makes it really easy to manage connections, transactions, and the sort, and integrates well with ORM tools like Hibernate or the JPA implementation.

Where Struts fits in in this is that it will manage the request, delegate to an action, which in turn will invoke a service that uses your data access layer. You could put your DAL in your actions, but I wouldn't -- I would put them in a service.

hvgotcodes