5608057 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Cast error OracleCallableStatement - Jboss 5 #418

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Put JavaMelody on the application
2. Try to call any procedure using OracleCallableStatement

What is the expected output? What do you see instead?
On the past, when my server was without JavaMelody my application works fine, 
so I'd put JavaMelody on my application and now I'm getting an error while 
calling the procedure.

What version of the product are you using? On what application server, JDK,
operating system?
javamelody-1.51.0
Jboss 5.1
Java 6
Linux or Windows

Please provide any additional information below.
Code:
sessao = ServiceLocatorDAO.getInstance().getHibernateSession();
conn = sessao.connection();
selectWrapped = (WrappedCallableStatement)conn.prepareCall(SQL);
select = (OracleCallableStatement) selectWrapped.getUnderlyingStatement();

Error:
java.lang.ClassCastException: oracle.jdbc.driver.$Proxy207 cannot be cast to 
oracle.jdbc.driver.OracleCallableStatement

Original issue reported on code.google.com by roger.tu...@gmail.com on 10 Jul 2014 at 8:01

GoogleCodeExporter commented 8 years ago
First, why do you cast to OracleCallableStatement?
It's bad practice and you do not need that to call a stored procedure. You can 
use only the standard java.sql API.

Then, if you want to cast to OracleCallableStatement, use in your code the 
Statement.unwrap method first.
It was created for that in the java.sql API
http://docs.oracle.com/javase/6/docs/api/java/sql/Wrapper.html#unwrap%28java.lan
g.Class%29

Original comment by evernat@free.fr on 11 Jul 2014 at 2:09

GoogleCodeExporter commented 8 years ago
I know that, but my server has lots of old applications with bad practices of 
programming. Okay, so to put JavaMelody in this environment I've to fix these 
problems first. Right, this is the only solution?

Original comment by roger.tu...@gmail.com on 14 Jul 2014 at 12:35

GoogleCodeExporter commented 8 years ago
yes

Original comment by evernat@free.fr on 14 Jul 2014 at 12:53

GoogleCodeExporter commented 8 years ago
Ok, thank you.

Original comment by roger.tu...@gmail.com on 14 Jul 2014 at 1:19

GoogleCodeExporter commented 8 years ago
I hava a question, can I turn off the SQL monitoring for while, till I fix my 
application problems, is that possible?

Original comment by roger.tu...@gmail.com on 17 Jul 2014 at 2:23

GoogleCodeExporter commented 8 years ago
I suggest that you fix your code instead.

Original comment by evernat@free.fr on 18 Jul 2014 at 11:42