Hello ,

I am new to Struts and facing problem regarding the Database access .I m getting 
DataSource as null even though , i ve done changes in Data Source Configuratio .
I m using Tomcat 3.2.1 .

This is what I have done in struts-config.xml file 
-------------------------------------------------------------------
 <data-sources>
    <data-source key="org.apache.struts.action.DATA_SOURCE" 
type="org.apache.struts.util.GenericDataSource">
      <set-property property="autoCommit"
                       value="false"/>
      <set-property property="description"
                       value="Example Data Source Configuration"/>
      <set-property property="driverClass"
                       value="oracle.jdbc.driver.OracleDriver"       
      <set-property property="maxCount"
                       value="4"/>
      <set-property property="minCount"
                       value="2"/>
      <set-property property="password"
                       value="sree"/>
      <set-property property="url"
                    value="jdbc:oracle:thin:@199.100.100.100:1521:prod"
      <set-property property="user"
                       value="sree"/>
    </data-source>
  </data-sources>
-------------------------------------------------------------------
And my web.xml has context 
-------------------------------------
<context-param>
      <param-name>org.apache.struts.action.DATA_SOURCE</param-name>
      <param-value>org.apache.struts.util.GenericDataSource</param-value>
  </context-param>
-------------------------------------
My Action class reads as below to get the connection
----------------------------------------------------------
    javax.sql.DataSource dataSource  =    
servlet.findDataSource("org.apache.struts.action.DATA_SOURCE");
    java.sql.Connection myConnection =    dataSource.getConnection();
    java.sql.Statement st  =  myConnection.createStatement();    
    int x   =  st.executeUpdate( " Some _ Query ");

----------------------------------------------------------

I m getting dataSource as null.

What do you have to say bout this ?  Is there anything wrong. Please let me know .
Thanks in advance.

- Sager

Reply via email to