Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WebSphere and DB2 autogenerated id

 
U Kvistborg
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am getting an exception when trying to create a cmp 2.x instance of a bean that have the PK field in the database as autogenerated by the database.

I see that in this generated java file that it is an plain insert into statement where it sets the key value to java.sql.Types.BIGINT (-5 in this implementation), so how do I get around this ?

I want to have the db2 generate my key field, but if I do not set it during the create method for my bean, it fails with this exception. Is it even possible to have these fields in the database as PK's and still be able to get to use it as the beans pk ?

Currently I do not see anyway around this issue except having the code create the id, and not have an autogenerated pk in the table ?

Sorry for the danish, but DB2 did not get me to choose english during the installation.

---- Begin backtrace for Nested Throwables
com.ibm.db2.jcc.b.SqlException: Der opstod en fejl ved udførelse af en implicit systemhandling af typen "2". Den information, der er returneret om fejlen, indeholder SQLCODE "-798", SQLSTATE "428C9" og meddelelsessymbolerne "AVAILABILITYID".
at com.ibm.db2.jcc.b.zc.e(zc.java:1606)
at com.ibm.db2.jcc.b.ad.a(ad.java:1698)
at com.ibm.db2.jcc.a.db.a(db.java:200)
at com.ibm.db2.jcc.a.db.b(db.java:88)
at com.ibm.db2.jcc.a.r.b(r.java:60)
at com.ibm.db2.jcc.a.tb.d(tb.java:293)
at com.ibm.db2.jcc.b.ad.ab(ad.java:1691)
at com.ibm.db2.jcc.b.ad.db(ad.java:1762)
at com.ibm.db2.jcc.b.ad.d(ad.java:2203)
at com.ibm.db2.jcc.b.ad.V(ad.java:521)
at com.ibm.db2.jcc.b.ad.executeUpdate(ad.java:504)
at com.ibm.ws.rsadapter.cci.WSResourceAdapterBase.executeUpdate(WSResourceAdapterBase.java:450)
at com.incase.iss.ejb.cmp.websphere_deploy.DB2UDBNT_V82_1.AvailabilityBeanFunctionSet_d4aab7c6.Create(AvailabilityBeanFunctionSet_d4aab7c6.java:78)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic