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

issue typecasting java.sql.CallableStatement into oracle.jdbc.driver.OracleCallableStatement

 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written a test class in which I've typecasted java.sql.CallableStatement into oracle.jdbc.driver.OracleCallableStatement and it's works fine.
the code is:-


When I put the code in an ejb business method and invoke the method, it throws java.lang.ClassCastException at line #456

I don't have any clue why it's behaving like this. Will anybody help me???

Thanks in advance.
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you get a OracleCallableStatement compatible object from your con.prepareCall()?
 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The same piece of code works fine in the standalone utilty.

OracleCallableStatement interface implements java.sql.CallableStatement()here so we can very well
go for explicit casting.

Don't you think so?
 
nandini lagunia
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
con.prepareCall() returns java.sql.CallableStatement.
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nandini lagunia wrote:con.prepareCall() returns java.sql.CallableStatement.
Do you know the exact class that it returns in your case,
both for the standalone and not so standalone use case?

you can use the getName() method on cs in both cases. Wonder if there is a difference in the two cases...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic