You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by sbelt <sb...@zeroton.com> on 2002/01/22 20:30:00 UTC

Suggestions on how to dynamically insert rows into the id_table?

First, I want to thank you all for your help so far. I have moved along
quite far on my project (on which I am the sole developer), and have
received many "pats on the back" from my boss. It seems only fitting that I
pass along these kudos to the turbine team.

I am now working on a feature which requires number sequences. My plan was
to use the IDBroker to generate them for me. My question - I hope - is
relatively simple: How can I dynamically connect to the id_table and add a
row of data? Unfortunately, I have been spoiled by the ant scripts, so I am
not clear on what turbine methods would be involved.

BTW - I am using Torque stand-alone using a CVS from Jan 7 connecting to
PostgreSql on Linux.

TIA
Steve B.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[solved]Re: Suggestions on how to dynamically insert rows into the id_table?

Posted by sbelt <sb...@velos.com>.
Pardon this conversation with myself, but I wanted to post the solution so
that users searching the archives can avoid wasting the time I did; or
perhaps I am simply documenting my ignorance :)

Putting several println statements, I found that Torque.getDBConnection was
returning a non-null value. I mistakenly assumed that this meant all my
calls to this point were correct...wrong!

I then fond that the dbCon.getConnection was causing the displayed error.
This reminded me of a similar problem someone helped me with previously.

The problem is that my PostgreSql database name is nDB; however, my
ndb.properties file uses the parameter ndb. When I made the case-sensitive
correction, everything worked great.

I am now able to implement John McNally's suggestion for my final solution.

Thanks as Always!
Steve B.

----- Original Message -----
From: "sbelt" <sb...@velos.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Wednesday, January 23, 2002 3:16 AM
Subject: Re: Suggestions on how to dynamically insert rows into the
id_table?


> Thanks for the suggestion John. I tried what you said, but I keep getting
an
> exception whenever I try to use the BasePeer methods.
> My BasePeer calls give exception:
>
> java.sql.SQLException: Connection object is null!
>
> I also tried creating a Criteria object then then calling the
> BasePeer.doInsert(Criteria) method - same error.
> I even tried fetching my own dbCon from the torque pool (verified it was
not
> null) then calling BasePeer.doInsert(Criteria, dbCon).
>
> Any ideas?
>
> Thanks as always!
> Steve B.
>
> ----- Original Message -----
> From: "John McNally" <jm...@collab.net>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Tuesday, January 22, 2002 2:33 PM
> Subject: Re: Suggestions on how to dynamically insert rows into the
> id_table?
>
>
> > Here is how we do it in scarab.  Certainly not the most efficient code
> > ever written, but we do not add rows that often:
> >
> >     private void saveIdTableKey(String dbName)
> >         throws Exception
> >     {
> >         String key = getIdTableKey();
> >
> >         // FIXME: UGLY! IDBroker doesn't have a Peer yet.
> >         String sql = "insert into " +
> >             IDBroker.TABLE_NAME.substring(0,
> > IDBroker.TABLE_NAME.indexOf('.'))
> >             + " set " +   IDBroker.TABLE_NAME + "='" + key + "'," +
> >             IDBroker.NEXT_ID  + "=1," + IDBroker.QUANTITY  + "=1";
> >         BasePeer.executeStatement(sql, dbName);
> >     }
> >
> > john mcnally
> >
> > sbelt wrote:
> > >
> > > First, I want to thank you all for your help so far. I have moved
along
> > > quite far on my project (on which I am the sole developer), and have
> > > received many "pats on the back" from my boss. It seems only fitting
> that I
> > > pass along these kudos to the turbine team.
> > >
> > > I am now working on a feature which requires number sequences. My plan
> was
> > > to use the IDBroker to generate them for me. My question - I hope - is
> > > relatively simple: How can I dynamically connect to the id_table and
add
> a
> > > row of data? Unfortunately, I have been spoiled by the ant scripts, so
I
> am
> > > not clear on what turbine methods would be involved.
> > >
> > > BTW - I am using Torque stand-alone using a CVS from Jan 7 connecting
to
> > > PostgreSql on Linux.
> > >
> > > TIA
> > > Steve B.
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Suggestions on how to dynamically insert rows into the id_table?

Posted by sbelt <sb...@velos.com>.
Thanks for the suggestion John. I tried what you said, but I keep getting an
exception whenever I try to use the BasePeer methods.
My BasePeer calls give exception:

java.sql.SQLException: Connection object is null!

I also tried creating a Criteria object then then calling the
BasePeer.doInsert(Criteria) method - same error.
I even tried fetching my own dbCon from the torque pool (verified it was not
null) then calling BasePeer.doInsert(Criteria, dbCon).

Any ideas?

Thanks as always!
Steve B.

----- Original Message -----
From: "John McNally" <jm...@collab.net>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Tuesday, January 22, 2002 2:33 PM
Subject: Re: Suggestions on how to dynamically insert rows into the
id_table?


> Here is how we do it in scarab.  Certainly not the most efficient code
> ever written, but we do not add rows that often:
>
>     private void saveIdTableKey(String dbName)
>         throws Exception
>     {
>         String key = getIdTableKey();
>
>         // FIXME: UGLY! IDBroker doesn't have a Peer yet.
>         String sql = "insert into " +
>             IDBroker.TABLE_NAME.substring(0,
> IDBroker.TABLE_NAME.indexOf('.'))
>             + " set " +   IDBroker.TABLE_NAME + "='" + key + "'," +
>             IDBroker.NEXT_ID  + "=1," + IDBroker.QUANTITY  + "=1";
>         BasePeer.executeStatement(sql, dbName);
>     }
>
> john mcnally
>
> sbelt wrote:
> >
> > First, I want to thank you all for your help so far. I have moved along
> > quite far on my project (on which I am the sole developer), and have
> > received many "pats on the back" from my boss. It seems only fitting
that I
> > pass along these kudos to the turbine team.
> >
> > I am now working on a feature which requires number sequences. My plan
was
> > to use the IDBroker to generate them for me. My question - I hope - is
> > relatively simple: How can I dynamically connect to the id_table and add
a
> > row of data? Unfortunately, I have been spoiled by the ant scripts, so I
am
> > not clear on what turbine methods would be involved.
> >
> > BTW - I am using Torque stand-alone using a CVS from Jan 7 connecting to
> > PostgreSql on Linux.
> >
> > TIA
> > Steve B.
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Suggestions on how to dynamically insert rows into the id_table?

Posted by John McNally <jm...@collab.net>.
Here is how we do it in scarab.  Certainly not the most efficient code
ever written, but we do not add rows that often:

    private void saveIdTableKey(String dbName)
        throws Exception
    {
        String key = getIdTableKey();

        // FIXME: UGLY! IDBroker doesn't have a Peer yet.
        String sql = "insert into " + 
            IDBroker.TABLE_NAME.substring(0,
IDBroker.TABLE_NAME.indexOf('.'))
            + " set " +   IDBroker.TABLE_NAME + "='" + key + "'," +
            IDBroker.NEXT_ID  + "=1," + IDBroker.QUANTITY  + "=1";
        BasePeer.executeStatement(sql, dbName);
    }

john mcnally

sbelt wrote:
> 
> First, I want to thank you all for your help so far. I have moved along
> quite far on my project (on which I am the sole developer), and have
> received many "pats on the back" from my boss. It seems only fitting that I
> pass along these kudos to the turbine team.
> 
> I am now working on a feature which requires number sequences. My plan was
> to use the IDBroker to generate them for me. My question - I hope - is
> relatively simple: How can I dynamically connect to the id_table and add a
> row of data? Unfortunately, I have been spoiled by the ant scripts, so I am
> not clear on what turbine methods would be involved.
> 
> BTW - I am using Torque stand-alone using a CVS from Jan 7 connecting to
> PostgreSql on Linux.
> 
> TIA
> Steve B.
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>