strut problem

i set strut-config and set jdbc driver

still not run this code

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import java.sql.*;

publicclass TestDataSourceextends Action

{

public ActionForward execute(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)throws Exception{

javax.sql.DataSource dataSource;

java.sql.Connection myConnection=null;

try{

dataSource = getDataSource(request);

myConnection = dataSource.getConnection();

Statement stmt=myConnection.createStatement();

ResultSet rst=stmt.executeQuery("select * from test");

System.out.println("******************************************");

System.out.println("********Out Put from TestDataSource ******");

while(rst.next()){

System.out.println("User Name is: " + rst.getString("username"));

}

System.out.println("******************************************");

rst.close();

stmt.close();

// do what you wish with myConnection

}catch (SQLException sqle){

System.out.println("sql"+sqle);

getServlet().log("Connection.process", sqle);

}finally{

//enclose this in a finally block to make

//sure the connection is closed

try{

myConnection.close();

}catch (SQLException e){

System.out.println("e1"+e);

getServlet().log("Connection.close", e);

}

}

javax.servlet.ServletException

org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)

javax.servlet.http.HttpServlet.service(HttpServlet.java:689)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException

TestDataSource.execute(TestDataSource.java:43)

org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)

org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)

org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)

org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)

org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)

javax.servlet.http.HttpServlet.service(HttpServlet.java:689)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

[4521 byte] By [Java_Jsp_servleta] at [2007-11-27 9:38:39]
# 1
java.lang.NullPointerExceptionTestDataSource.execute(TestDataSource.java:43)so fix that.
CeciNEstPasUnProgrammeura at 2007-7-12 23:12:23 > top of Java-index,Java Essentials,New To Java...