Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts & DBCP : getting Null Datasource

 
vijay saraf
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
i am trying to obtain connection from database connection pool,but i am getting null object of DataSource.
Here is my code :
i have place this line in my Action Class
DataSource dataSource = getDataSource(request);
and these lines in struts-congig.xml
<data-sources>
<data-source key="connectionpool" type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
<set-property property="url" value="jdbc:jtds:sqlserver://vijays/master"/>
<set-property property="maxActive" value="5" />
<set-property property="username" value="myaccount" />
<set-property property="password" value="mypass" />
<set-property property="autoCommit" value="true" />
<set-property property="maxWait" value="5000" />
</data-source>
</data-sources>
i have placed all the jars in class path.
Please tell me is there any more settings needed (like jndi related..)

Thanks.
Vijay Saraf.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic