Ooh, I worked too late last night to have this type of error.
--
--------- Original Message ---------
DATE: Sun, 14 Dec 2003 20:28:40
From: Dirk Verbeeck <[EMAIL PROTECTED]>
To: Jakarta Commons Users List <[EMAIL PROTECTED]>
Cc:
>You declared "DataSource ds" inside the constructor and that "ds" is
>being initialized and not the "private DataSource ds".
>
>-- Dirk
>
>
>Vernon Smith wrote:
>> 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.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
____________________________________________________________
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]