Wednesday, March 27, 2013

DB2 SQL Error: SQLCODE=-805, SQLSTATE=51002, SQLERRMC=NULLID.SYSLH203

I encountered this exception when running a custom batch job in WCS which used JDBCHelper to update data into WCS Tables.

The reason for this is that the JDBCConnection was not closed.
It looks like we need to close and open the connection frequently, else it results in too many open statements and results in this error.

Tuesday, March 26, 2013

Obtaining Primary Key while using JDBCHelper

If you plan to insert a new record into a WCS OOB or Custom table using JDBCHelper, you should ensure that there is no conflict between the EJBs and your program.

The KEYS.PREFETCHSIZE field reserves  a block of primary key values for use between the EJBs, so if you try doing an insert by doing SELECT MAX+1 then , it would result in Duplicate Key exception.

To avoid this, use the KeysManager to get the next primary key for using in JDBCHelper.

long
primaryKeyId= com.ibm.commerce.key.ECKeyManager.singleton().getNextKeyAsLong("table_name");
This would ensure you do not pick up a Key which is already being used by the EJBs.







Labels: , ,