users@glassfish.java.net

RE: Null Pointer Exception using Connetion class

From: Kenneth Clark <kenneth.clark_at_skyetech.co.za>
Date: Mon, 5 Nov 2007 18:14:59 +0200

Are you using wrapped connections?


________________
Thanks and regards

Kenneth Clark
Solutions Engineer


Tel: 27 11 679 3075
Mobile: 27 (0) 84 583 1348
Email: kenneth.clark_at_skyetech.co.za
Website: http://www.skyetech.co.za


-----Original Message-----
From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
Sent: 05 November 2007 18:18
To: users_at_glassfish.dev.java.net
Subject: Null Pointer Exception using Connetion class

Hi,

[code]public class BuildCms {
    DataSource db;
    static Connection conn;
    // initialize DB connection in constructor
    public BuildCms() throws NamingException, SQLException {
        db= BuildCms.getJdbcPwacms();
        conn = db.getConnection();
    }

    public static DataSource getJdbcPwacms() throws NamingException {
        Context c = new InitialContext();
        return (DataSource) c.lookup("XXXXXXXXXXXXX");
    }
    
    public static String getCMSPage(String page) throws NamingException, SQLException {
        
  #####ERROR#####
      Statement state = conn.createStatement();

[/code]
The above code compiles fine but glassfish returns a nullpointer exception when the code is called from a servlet. I have no idea why? Can anyone please help me here?

Thanks
[Message sent by forum member 'hughacland' (hughacland)]

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

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.22/1111 - Release Date: 2007/11/05 04:36
 

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.22/1111 - Release Date: 2007/11/05 04:36