After following the TC instruction configure the DBCP with the container, I create a 
class to make a cleaner interface. 

public class DBCPWrapper {
        private DataSource ds;

        public DBCPWrapper() {
                try {
                        Context ctx = new InitialContext();
                        if (ctx == null)
                                throw new Exception("Boom - No Context");
                        DataSource ds =
                                (DataSource) ctx.lookup("java:comp/env/jdbc/postgres");
                        } catch (Exception e) {
                                e.printStackTrace();
                }
        }

        public Connection getConnection() throws SQLException {
                Connection conn  = ds.getConnection(); <-- ds is NULL
                return conn;
        }
}

I don't understand why the data source is null in the getConnection method. I fix this 
problem by moving the body of the construtor into the getConnection method. I am not 
sure that is a right approach thought. Is a better way to get the thing done?

Thanks for your inputs.




____________________________________________________________
Free Poetry Contest. Win $10,000. Submit your poem @ Poetry.com!
http://ad.doubleclick.net/clk;6750922;3807821;l?http://www.poetry.com/contest/contest.asp?Suite=A59101

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to