• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

configuring datasource in struts-config.xml

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am learning Struts and I want how to configure the data source in struts-config.xml. i.e., connection to a database. it can be either oracle / sql server. I am trying to add the username and password in the DB. (all the action, actionforms are ready). pls tell / sample site for configuring db in struts-config.xml
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the reply that I got here in regard to database access - should prove useful to you.
https://coderanch.com/t/54917/Struts/Database-connection-method
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

struts-config.xml
=================

<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource" key="userDB">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="url" value="jdbc racle:thin:@112.118.5.28:1521 rcl" />
<set-property property="username" value="seet" />
<set-property property="password" value="seet" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery" value="SELECT COUNT(*) FROM emp" />
</data-source>
</data-sources>

Ensure that all jar files related to Oracle and the dbcp datasource are present in the lib folder so that the build.xml has the following entries.

<path id="compile.classpath">
<pathelement path ="lib/struts-legacy.jar"/>
<pathelement path ="lib/commons-dbcp-1.2.1.jar"/>
<pathelement path ="lib/commons-pool-1.3.jar"/>
<pathelement path ="lib/classes12.jar"/>
<pathelement path ="lib/ojdbc14.jar"/>
......
</path>

Rgds,

Seetesh
reply
    Bookmark Topic Watch Topic
  • New Topic