• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unsupported Data Conversion - Due to returning primary Key

 
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
AS
BEGIN
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
END
GO
My XML insert method is as follows:
<env-entry>
<env-entry-name>ejipt.createSQL</env-entry-name>
<env-entry-value>{call spr_ins_ContactEvent (?,?,?,?,?,?,?,?,?,?)}</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>ejipt.createSQL.source</env-entry-name>
<env-entry-value>myjdbc</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>ejipt.createSQL.params</env-entry-name>
<env-entry-value>cSession,aSession,interactiveItemKey,accountKey,treatKey,methodOfContact,promoCode,direction,contactDate,contactEventKey UT</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>ejipt.createSQL.paramTypes</env-entry-name>
<env-entry-value>INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, CHAR, CHAR, CHAR, TIMESTAMP, INTEGER</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>ejipt.createSQL.fields</env-entry-name>
<env-entry-value>contactEventKey</env-entry-value>
</env-entry>

Can anyone see where my problem lies, or do you know if Microsoft SQL Server JDBC drivers always cause this problem?
Cheers in advance,
Fergus
 
Lilac Ezer
Greenhorn
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