You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anant Sagar <an...@rapideffect.com> on 2002/03/01 09:38:15 UTC
Re: Database Access Problem.Need Help?
Thanks Kanoza ,
I have tried and its working that way as well. In fact after posting my
query i tried to solve the problem .The problem was due to the Driver which
I was using , I changed the driver and it started working with the the
existing code.
But i m surprised why the Exception was not shown on the console rather I
was getting NullPointerException.
Rgds.
- Anant Sagar
----- Original Message -----
From: "Kanoza, Douglas (NCI)" <ka...@mail.nih.gov>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, February 28, 2002 7:44 PM
Subject: RE: Database Access Problem.Need Help?
> I've been using the DataSource for a while without any problems, but I
never
> explicitly specified the key or type properties in the data-source tag, or
> the context-param in web.xml. I just copied it right from the example app
> and put in my settings, but I'm using Tomcat 3.2.4 and 4.0.1. Also, I'm
not
> using findDataSource to get the source in my Action classes. I use:
>
> DataSource lSource = (DataSource)servlet.getServletContext()
> .getAttribute(Action.DATA_SOURCE_KEY);
>
> Hope that helps.
>
> -----Original Message-----
> From: Anant Sagar [mailto:anants@rapideffect.com]
> Sent: Thursday, February 28, 2002 5:16 AM
> To: 'Struts Users Mailing List'
> Subject: Database Access Problem.Need Help?
>
> 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
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>