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.OracleCallableStatementI 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 SPCode:
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);