I'm hoping to use Torque and the DB classes for standalone programs.

I wrote the following as a simple test:

public class AccountTest
{
    public static void main(String args[])
        throws Exception
    {
        // Setup Turbine.
        TurbineResourceService.setPropertiesFileName("db.properties");

        // Insert a new account.
        Account account = new Account();
        account.setAccountid(1);
        account.setDescription("test");
        AccountPeer.doInsert(account);
    }
}

When I ran it, I got a NullPointerException. I tracked it down to the ConnectionPool 
class. getDB() was returning null. I fixed ConnectionPool.java and all went 
beautifully!

Here's my proposed fixed to ConnectionPool.java (it used to just return db):

    public DB getDB()
        throws Exception
    {
        // PoolBrokerService keeps a collection of ConnectionPools,
        // each one of which contains connections to a single database.
        // The initialization of a pool should only occur once.
        if (db == null)
        {
           db = DBFactory.create( driver );
           db.init( url, username, password );
        }
        return db;
    }

and I changed getNewConnection() to use getDB.

If this is cool and if Jon would give me CVS write access, I'd be glad to check it in.

If I'm a newbie who's off-base, please be kind. :-)

Carl

--
Carl Ludewig
Director of Research & Development
AudioBase, Inc.
(415) 389-6875
[EMAIL PROTECTED]
http://www.audiobase.com/


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to