cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amir Azmi" <aa...@centervilletech.com>
Subject RE: Add action not working????
Date Fri, 02 Mar 2001 01:27:09 GMT
I have latest C2 CVS release, when I tried to run the sample for actions
provided in "employee.xsp" file, I was constantly getting NULL pointer
exception when I tried the "Add" action. Finally I managed putting it to
work. Following was the code that was originally their in the while loop
within "Act" method of "DatabaseAddAction" class,

********
            while (keys.hasNext()) {
                Configuration key = (Configuration) keys.next();
                if ("manual".equals(key.getAttribute("mode",
"automatic"))) {
                    String selectQuery = this.getSelectQuery(key);

                    ResultSet set =
conn.createStatement().executeQuery(selectQuery);
                    set.next();
                    int value = set.getInt("maxid") + 1;

                    statement.setInt(currentIndex, value);

                    set.close();
                    set.getStatement().close();
                    currentIndex++;
                }
            }

**********

Now I think NULL pointer exception was been thrown 'coz "set" resultset
was being closed first and then the statement associated with it. So
just by swapping the position of those two statements sample worked for
me.

Please correct me if I am wrong and did anyone had same code woking in
postgre(if yes then why do u think u didn't get an error).

Thanks,
Amir



-----Original Message-----
From: Berin Loritsch [mailto:bloritsch@apache.org]
Sent: Thursday, March 01, 2001 8:41 AM
To: cocoon-dev@xml.apache.org
Subject: Re: Add action not working????


Allan Erskine wrote:
> 
> how are your database tables set up?  On my postgres database I was
using
> the serial (autonumbering) type for my id column and had this problem
> 
> Try changing the keys element in employee.xml to read
>     <keys>
>       <key param="employee" dbcol="id" type="int" mode="automatic"/>
>     </keys>
> 
> or whatever's appropriate for your database.

Another thing is to make sure that your Driver allows you to use
explicit transactions.  I know that SQLServer2000 the database
can handle them, but the JdbcOdbcBridge driver won't.  You really
need a JDBC 2.0 compliant driver.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message