My problem, is that I cannot return my connection as defined in cocoon.xconf.
Here is a snippet of code (the significant bits) can anyone offer any advice.
I must warn you that I am a relative new comer to Java.
Anyway, I always get a java.lang.NullPointerException???????
I'm not sure if the compose method is ever called.
public class MySessionFilter implements HttpSessionAttributeListener, ThreadSafe, Composable, Disposable
{
private Connection con; private ResultSet rs;
protected ComponentSelector dbselector; protected ComponentManager manager;
public void compose(ComponentManager manager) throws ComponentException
{this.dbselector = (ComponentSelector) manager.lookup(DataSourceComponent.ROLE + "Selector");
}
public void dispose()
{
this.manager.release(dbselector);
}
protected final DataSourceComponent getDataSource(String pool) throws ComponentException { return (DataSourceComponent) this.dbselector.select(pool); }
public void attributeAdded(HttpSessionBindingEvent be)
{
Object sessionUser = be.getSession().getAttribute("user");
System.out.println("Attribute User " +sessionUser);
Connection conn = null;
try
{
// compose(manager);
DataSourceComponent dataSource = getDataSource("abc");
conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
String sql = "update calib_users set logged_in = 'Z' where username = 'simon'";
System.out.println("Updated");
ResultSet rs = stmt.executeQuery(sql);
}
catch (SQLException sqle)
{
System.out.println("No connection");
return;
}
catch (Exception e)
{ System.out.println("Problem!!");
e.printStackTrace();
}}
_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you. http://www.msn.co.uk/internetaccess
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
