-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: ClassCastException for SP call using datasource(oracle11g)
PostPosted: Wed Feb 02, 2011 6:58 am 
Newbie

Joined: Tue Feb 01, 2011 1:12 am
Posts: 1
Hi ,
Could you please look into this following issue.
I am using Hibernate3x and configuring two datasources(for different schema within same DB) in tomcat6 for oracle11g.I am calling store-procedure to retrieve specific data from DB using datasource in tomcat6.The fact is fetching data from different schema within same database is working properly but the exception occurs while calling the storeproc using datasource(same store proc works well without using datasource).
The exception throws is as follows.

java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement cannot be cast to oracle.jdbc.OracleCallableStatement

I apply the following steps for the above.
1.
hibernate_aar.cfg.xml
--------------------------
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/aardb</property>

hibernate_acc.cfg.xml
----------------------------
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/accdb</property>

2.
web.xml
---------------
<resource-ref> // aar schema
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/aardb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref> // acc schema
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/accdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

3.
Tomcat context.xml
----------------------
<Resource
name="jdbc/aardb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@10.227.30.204:1521:DB1"
schema="TEST_AAR_DVL"
username="TEST_AAR_DVL"
password="password1$"
initialSize ="0"
maxActive="10"
minIdle="0"
maxIdle="8"
maxWait="5000"
validationQuery="select 1 from dual"
/>
<Resource
name="jdbc/accdb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@10.227.30.204:1521:DB1"
schema="TEST_ACC_DVL"
username="TEST_ACC_DVL"
password="password1$"
initialSize ="0"
maxActive="10"
minIdle="0"
maxIdle="8"
maxWait="5000"
validationQuery="select 1 from dual"
/>
Note : ojdbc14.jar is kept in Tomcat/lib directory

the following code snippet is for calling SP
Code:
Connection connection = null;
CallableStatement cStatement = null;
ResultSet resultSet = null;
connection = session.connection();
cStatement = (OracleCallableStatement)connection.prepareCall("{call PROC_GET_POLICY_DETAILS(?,?,?,?,?,?,?,?,?)}");
cStatement.registerOutParameter(9, OracleTypes.CURSOR);
cStatement.execute();
resultSet = ((OracleCallableStatement) cStatement).getCursor(9);


Top
 Profile  
 
 Post subject: Re: ClassCastException for SP call using datasource(oracle11g)
PostPosted: Wed Mar 09, 2011 8:06 am 
Newbie

Joined: Wed Mar 09, 2011 7:47 am
Posts: 1
Hi,

I am running with the same problem. If you found any solution for this please suggest me?

I am getting the same problem when i tries to do the following steps:

1)I am using tomcat, I have configured the data source in context.xml with dbcp datasource as follows.
<Resource driverClassName="oracle.jdbc.OracleDriver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" name="xxx" password="xxx" type="javax.sql.DataSource" url="jdbc:oracle:thin:@xxxxx:1521:xxxxx" username="xxxxx"/>

2)when i am trying to access the configured datasource using the below way ..
Session session = SessionFactoryUtils.getSession(getSessionFactory(), false);
CallableStatement stmt = (OracleCallableStatement) session.connection().prepareCall(xxxxx);
I am getting the below Error..
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement cannot be cast to oracle.jdbc.OracleCallableStatement

My Restrictions to not use are :
I cannot configure it as a OracleDatasource. Please help...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.