I tried using the <datasources> tags in struts-config.xml, couldnt get it work so I modified the server.xml in tomcat/conf directly. Just add a context element as follows in your server.xml
This is my configuration: <Context path="/wrap" docBase="C:\tomcat5\webapps\wrap" reloadable="true"> <Resource name="jdbc/WrapDB" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/WrapDB"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <!-- Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit. --> <parameter> <name>maxActive</name> <value>200</value> </parameter> <!-- Maximum number of idle dB connections to retain in pool. Set to 0 for no limit. --> <parameter> <name>maxIdle</name> <value>10</value> </parameter> <!-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. --> <parameter> <name>maxWait</name> <value>20</value> </parameter> <!-- dB username and password for dB connections --> <parameter> <name>username</name> <value>(*********place your username here) </value> </parameter> <parameter> <name>password</name> <value>(*************place your password here)</value> </parameter> <!-- Class name for oracle JDBC driver --> <parameter> <name>driverClassName</name> <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:microsoft:sqlserver://(***********place your URL here)</value> </parameter> </ResourceParams> </Context> Hope this helps. -Asif ----- Original Message ----- From: "Koon Yue Lam" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, July 19, 2004 12:46 PM Subject: Datasource problem again.. > Hi ! > I have try the follow to retrieve a datasource from Struts using JNDI: > > Context initCtx = new InitialContext(); > Context envCtx = (Context) initCtx.lookup("java:comp/env"); > DataSource ds = (DataSource) envCtx.lookup("jdbc/kiss_web_news"); > > but it doesn't work.... > > it is my struts-config,xml: > <data-sources> > <data-source type="org.apache.commons.dbcp.BasicDataSource"> > <set-property > property="driverClassName" > value="org.gjt.mm.mysql.Driver" /> > <set-property > property="url" > value="jdbc:mysql://localhost/kiss_web_news" /> > <set-property > property="username" > value="root" /> > <set-property > property="password" > value="1234567" /> > </data-source> > </data-sources> > > Do I need to modify the web.xml under $Tomcat/conf ?? It seems that > Stucts doesn't registry the datasource to JNDI and I always get a null > pointer of datasource. > > any help? > > Regards > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]