users@glassfish.java.net

Re: RE: RE: Null Pointer Exception using Connetion class

From: <glassfish_at_javadesktop.org>
Date: Mon, 05 Nov 2007 09:07:32 PST

Thanks - the thing about this that puzzles me is that it only give the nullpointer exception while conn is defined as static. If I change to the following code and then (tediously and wastefully) insantiate a BuildCms object from the servlet it all works fine. .... Any ideas why?

[code]
public class BuildCms {
  
    public DataSource getJdbcPwacms() throws NamingException {
        Context c = new InitialContext();
        return (DataSource) c.lookup("java:comp/env/jdbc/pwacms");
    }
    
    public String getCMSPage(String page) throws NamingException, SQLException {
        DataSource db = this.getJdbcPwacms();
        
        Statement state = db.getConnection().createStatement();
        ResultSet results;
[/code]
[Message sent by forum member 'hughacland' (hughacland)]

http://forums.java.net/jive/thread.jspa?messageID=243899