This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unsupported Data Conversion - Due to returning primary Key  RSS feed

Fergus Red
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've asked a similiar question to this forum already but could not get it solved.
What I said before was that I am getting a "Unsupported Data Conversion" on trying to insert a value in a database using a create() method in my EJB.
I've now realised that the error occurs in my container managed EJB because I am trying to return the primary key value for my new record inserted.
If I do not try to retrieve this value from my insert, my insert works fine.
I am using Microsoft SQL Server JDBC Driver. Before this I was using a JDBC-ODBC bridge and the error did not occur but since I moved to my SQL Server driver my error results.
My Stored Procedure called is as follows:
CREATE PROCEDURE spr_ins_ContactEvent
@cSession int,
@aSession int,
@interactiveItemKey int,
@accountKey int,
@treatKey int,
@methodOfContact char(6),
@promoCode char(6),
@direction char(1),
@contactDate datetime,
@contactEventKey int OUTPUT
INSERT INTO contactEvent(cSession, aSession, interactiveItemKey, accountKey, treatKey, methodOfContact, promoCode, direction, contactDate)
VALUES (@cSession, @aSession, @interactiveItemKey, @accountKey, @treatKey, @methodOfContact, @promoCode, @direction, getDate())
SELECT @contactEventKey = MAX(contactEventKey) FROM contactEvent
My XML insert method is as follows:
<env-entry-value>{call spr_ins_ContactEvent (?,?,?,?,?,?,?,?,?,?)}</env-entry-value>
<env-entry-value>cSession,aSession,interactiveItemKey,accountKey,treatKey,methodOfContact,promoCode,direction,contactDate,contactEventKey UT</env-entry-value>

Can anyone see where my problem lies, or do you know if Microsoft SQL Server JDBC drivers always cause this problem?
Cheers in advance,
Lilac Ezer
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said that when you take out the Output parameter, this works. It may be required with this JDBC driver to register the Output param as follows:
CallableStatement cs......
cs.registerOutParameter(10, Types.INTEGER);
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!