Hello all, I have some problem in conncting with the database using struts application please tell me how to connect for ms-access databse, where to include that (jdbc dbc:Jdbcodbc) bridge ,where to include dsn. iam confused please help me.
look you can access the database by entering this code in struts-config.xml below is the code to enter <data-sources> <data-source type="org.apache.commons.dbcp.BasicDataSource"> <set-property property="driverClassName" value="com.mysql.jdbc.Driver" /> <set-property property="url" value="jdbc:mysql://localhost/retail" /> <set-property property="username" value="root" /> <set-property property="password" value="root" /> </data-source> </data-sources> in the place of driverclassName put your jdbc dbc bridge and on the url place put the database name with the required things.
and now in the action class you can use this.
DataSource dataSource=getDataSource(HttpServletRequest); Connection con=dataSource.getConnection() and now the rest things are as usual...
I'd advise against using the Struts DataSource configuration utility. It's deprecated in later versions, so it would make your application more difficult to upgrade. It also has portability issues. I've seen instances where it worked fine in development, but didn't work when the application was ported to production.
The best practice for connecting to a JDBC DataSource in a Struts or any J2EE Web Application is to define the DataSource as a JNDI resource using your Application Server's preferred method and then using JNDI to look up the DataSource in your application code. If you're using Tomcat, this link explains how to do it.
Also see question 7 in the JavaRanch Struts FAQ. [ March 20, 2007: Message edited by: Merrill Higginson ]