This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Websphere and the fly likes WebSphere and DB2 autogenerated id Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "WebSphere and DB2 autogenerated id" Watch "WebSphere and DB2 autogenerated id" New topic
Author

WebSphere and DB2 autogenerated id

U Kvistborg
Greenhorn

Joined: Oct 14, 2002
Posts: 29
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)


SCJP 1.4/1.5, SCWCD 1.4, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WebSphere and DB2 autogenerated id