No, I am getting same error every time This is my
struts config.xml
I am getting Error HTTP 404
servlet action not available. If i am not using dtasource and changing action class my application runs without datasource and gets hard coded value from getquote method. I want value from db
<struts-config>
<data-sources>
<data-source
type="org.apache.common.dbcp.BasicDataSource">
<set-property property="driverClassName"
vlaue="oracle.jdbc.driver.OracleDriver"/>
<set-property property="url"
vlaue="jdbc
racle:thin:
@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost)(PORT=1521))(CONNECT_DATA=(SID=orcl)))"/>
<set-property property="username"
vlaue="scott"/>
<set-property property="password"
vlaue="tiger"/>
</data-source>
</data-sources>
<form-beans>
<form-bean name="lookupForm"
type="ch03.LookupForm"/>
</form-beans>
<action-mappings>
<action path="/Lookup"
type="ch03.LookupAction"
name="lookupForm">
<forward name="success" path="/quote.jsp"/>
<forward name="failure" path="/index.jsp"/>
</action>
</action-mappings>
<message-resources parameter="MessageResources" />
</struts-config>
This is my action class
public class LookupAction extends Action
{
public Double getQuote(
String symbol,
HttpServletRequest request)
throws Exception
{
Double price=null;
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
DataSource dataSource=null;
try
{
dataSource = getDataSource(request);
conn= dataSource.getConnection();
stmt= conn.createStatement();
rs= stmt.executeQuery("select * from stocks where" + "symbol='" + symbol +"'");
if (rs.next())
{
double tmp=0;
tmp = rs.getDouble("price");
price= new Double(tmp);
System.err.println("price:" +price);
}
else
{
System.err.println("Symbol not found returning null");
}
}
catch(SQLException e)
{
System.err.println(e.getMessage());
}
finally
{
if (rs!= null)
{
try
{
rs.close();
}
catch (SQLException sqle)
{
System.err.println(sqle.getMessage());
}
rs=null;
}
if (stmt!=null)
{
try{ stmt.close(); }
catch (SQLException sqle)
{
System.err.println(sqle.getMessage());
}
stmt=null;
}
if (conn!=null)
{
try{ conn.close(); }
catch (SQLException sqle)
{
System.err.println(sqle.getMessage());
}
conn=null;
}
}
return price;
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception{
Double price=null;
String target=new String("success");
if(form !=null)
{
LookupForm lookupForm = (LookupForm) form;
String symbol = lookupForm.getSymbol();
price = getQuote(symbol,request);
}
if(price == null)
{
target = new String("failure");
}
else
{
request.setAttribute("PRICE",price);
}
return(mapping.findForward(target));
}
}
Please Guide me its very urgent. I also want to know do we require any driver to place anywhere? Also without using struts config can i directly connect to DB? Please help me
Thanks
Lalit