ClassCastException casting CallableStatement into OracleCallableStatement
Well, i have configured Jakarta DBCP 1.1 with Jakarta Tomcat 4.1.29, JDK 1.4.2, with a database Oracle 9i over Win32 Platform.
Everything works fine if i use Statements and make SQL sentences. But when i try to execute a stored procedure with a callable statement, i need to pass it a CLOB parameter, so i need to cast a CallableStatement into a OracleCallableStatement, to use the Oracle Extensions. This process makes a ClassCastException.
This process works fine without DBCP, using just a connection, but fails when use DBCP connection pool.
I have tried to cast the Connection into OracleConnection that i get from the pool, but i get the same error. Also I have checked Connection is not null and connection works.
Could anyone gimme a solution? Thanx for your help!
Can't you use method getClob from CallableStatement, and then pass the data to the clob using setCharacterStream(...)?
BTW, I think DBCP wraps the genuine Oracle classes, which is the reason that your objects are not instances of Oracles classes.
Similar Messages
-
ClassCastException casting CallableStatement to OracleCallableStatement
Im trying to create a ViewObject based on a REF_CURSOR returned by PL/SQL stored procedure OUT parameter.
I casted the normal CallableStatement to OracleCallableStatement so I can call the OracleCallableStatement.getCursor(index);
CallableStatement statement = getDbTransaction.createCallableStatement(statementString, DbTransaction.DEFAULT);
ResultSet rs = ((OracleCallableStatement)statement).getCursor(1);I get a "java.lang.ClassCastException: oracle_jdbc_driver_T4CCallableStatement_Proxy" when I run this piece of code.
Jdeveloper version is Jdev10.1.3.1 Preview.
regards,
AntonI got a resolution for this. The reason for this exception is that I got the wrong import for the OracleCallableStatement. The correct import is "import oracle.jdbc.OracleCallableStatement" instead of "import oracle.jdbc.driver.OracleCallableStatement"
See the related thread:
Re: Dive into BC4J related --REF CURSOR (executeQueryForCollection)
regards,
Anton -
I'm using java reflection to return value of an attribute from a Class. The attribute is a float primitive. However, the return form is an Object. How do I cast it into the float primitive again?
Thanks.
LGFrom the API for Method.invoke: >>if the value has a primitive type, it is first appropriately wrapped in an object<<
So if the method returns a float primitive, Method.invoke will return a Float object. -
Can we type cast class into interface?
Hello all,
Can we type cast class into interface?
If it can ,pls explain me in which suituation can we do?You don't need to explicitly typecast a class to an interface, if the class is implementing the interface.
Example: List list = new ArrayList(); // Cast not required.And search on Google first. I'm sure this question would be answered by the lamest of tutorials. -
Casting byte [] into int
I have a typcal problem.
I have two bytes array and i wantto cast that into int type and have four byte array which i have to cast into long.
can anyone help me..
thanks in advance
Sai Burrapublic int toInt(byte[] bytes) {
return (bytes[0] << 8) | bytes[1];
}Note this actually returns a short, since a Java int is a 32-bit number, and this returns 16 bits worth of number.
There's no way to directly cast a non-primitive type (an array) to a primitive type (an int). -
Question about casting objects into Number
This might sound a bit silly, but i have a function that
casts an Object into a Number and then checks if it is NaN to
ensure that it is indeed a number, it returns true if it is a valid
number or false if it isn't a number
Now i have a TextInput and when i type for example "HELLO"
and call the function it returns false (since that is not a
number), if i type 23 it returns true (it is a number), if i type
"20a" it returns false. Everything works fine except for one
combination, if i type any number and the letter "e", for example
2e, 9E, 5e, etc, it returns true, which means this is a valid
Number, why is this?I thought it might be that, but for my bussiness logic, 2e is
not a valid number.......will i need to parse the string and
validate it? -
ClassCastException casting to a OracleConnection in Jdeveloper
Hi all,
Figured somebody on the list may know the answer to this one. Sounds to me like configuration step that I am missing.
I am running jdev 9031
I get a
java.lang.ClassCastException: com.evermind.sql.OrclCMTConnection
at tv.thirdspace.ova.debug.QueryTag.doEndTag(QueryTag.java:132)
at jsps.debug._debug._jspService(debug.jsp:24)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
at run time when I execute a jsp tag lib.
I am doing the following in the tag lib
try {
Context env = (Context) new InitialContext().lookup("java:comp/env");
ds = (DataSource) env.lookup("jdbc/TestConnectionPool");
}catch (NamingException e) {System.out.println(e.getMessage());}
conn = (OracleConnection)ds.getConnection();
It is failing when I attempt to cast the connection as a OracleConnection.
The data-sources.xml has the following datasource definition
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="TestConnectionPool"
location="jdbc/TestConnectionPool"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/TestConnectionPool"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@infinity:1521:test"
inactivity-timeout="30"
/>
What am I missing??
- ManishIn the current version there is a restriction that you can only really have one (diagrammed) Struts configuration per project, as such we disable the option to create a new pageflow in the New gallery. What may be happening is that we're not recognising the fact that the existing xml file is a struts config (maybe the <!DOCTYPE > is wrong / missing? ) so we allow you to add a second and that messes things up.
See:
http://www.oracle.com/technology/products/jdev/howtos/10g/StrutsMultiConfigs/struts_multiconfig_howto.html -
Warning when casting object into generic type at run time.
I am getting this message when casting an object at run time:
Type safety: The cast from Object to Tree<V> is actually checking against the erased type TreeI'm overloading an equals(Object o) method in my class.
Is there a way to get rid of the warning (besides turning the warning off :))I'm overloading an equals(Object o) method in my
class.
Is there a way to get rid of the warning (besides
turning the warning off :))No. The best you can do is what is demonstrated in the previous link. -
ClassCastException while adding into java 1.4 TreeSet
Hi Folks,
I am adding two objects to a java 1.4 TreeSet, and I get a ClassCastException.
I have implemented Comparable for the class. And the two objects are not equal by the compareTo method that I have coded up.
Any clues,
ThanksPlaying around with the code a bit, I get this:
import java.util.*;
public class TimeStructure implements Comparable
private String scheduleName;
private Date time;
public int compareTo(Object timeObject)
int retVal = 0;
if (time.before(((TimeStructure) timeObject).getTime()))
retVal = -1;
else if (time.after(((TimeStructure) timeObject).getTime()))
retVal = 1;
return retVal;
//Junit
public void testAdditionIntoATree() throws Exception
TreeSet set = new TreeSet();
Date time = new Date();
Date time1 = new Date(time.getTime() - 1000);
TimeStructure ts1 = new TimeStructure("testSchedule", time);
TimeStructure ts2 = new TimeStructure("testSchedule", time1);
if(ts1.compareTo(ts2) == -1) {
System.out.println("-1");
} else if(ts1.compareTo(ts2) == 1) {
System.out.println("1");
} else {
System.out.println("0");
set.add((Object)ts1);
set.add((Object)ts2);
// End of original code
public TimeStructure(){
this("Test", new Date());
public TimeStructure(String str, Date time){
scheduleName = str;
this.time = time;
public Date getTime(){
return this.time;
public static void main(String[] args) throws Exception{
TimeStructure t = new TimeStructure();
t.testAdditionIntoATree();
}which is not much different from your code. I only added some extra methods so it would compile. I am using JDK 6, and I am not getting any exceptions. Could you post the stack trace? -
How to cast jstring into CString
I am using JNI and want to convert jstring into CString and vice versa. Please let me knwo the solution
You can read about it at: http://www.science.uva.nl/ict/ossdocs/java/tutorial/native1.1/implementing/string.html
http://www.excelsior-usa.com/jet.html
JVM based on Ahead-of-Time compilation -
I am trying to send an array to a pl/sql module but for some reason i am unable to get the connection object.
Here is the line of code that fails
Connection conn = null;
ArrayDescriptor rectabDescriptor = ArrayDescriptor.createDescriptor("CCS21_CONSIGNMENTLIST_TYPE",conn); <<FAILS HERE<<
ARRAY awbNoHwbs = new ARRAY(rectabDescriptor,conn,childLessAwbs);
ARRAY hwbs = new ARRAY(rectabDescriptor,conn,hwbList);
OracleCallableStatement cst = (OracleCallableStatement)conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
Here is the stack trace
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement
at com.acbt.ccstt.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:301)
at com.acbt.ccstt.presentation.events.consignments.select.SubmitDeclaration.midAction(SubmitDeclaration.java:68)
at com.acbt.ccstt.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:36)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)And here is my connection config
Struts Web.xml file
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/ccs21db</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>Metainf/context.xml
<Resource name="jdbc/thedb" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:dbsid"
username="xxx" password="xxx" maxActive="20" maxIdle="10"
maxWait="-1"/> Edited by: ziggy on Sep 26, 2008 4:02 PMziggy wrote:
OracleCallableStatement cst = (OracleCallableStatement)conn.prepareCall(stp.SUBMIT_CONSIGNMENT_STORED_PROC);
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement
Why are you casting CallableStatement to OracleCallableStatement? The JDBC API is intented to be completely implementation independent. Never cast interfaces to implementation specific classes, it will break your app sooner or later. -
ClassCastException - While type casting Home object after EJB JNDI Lookup
Sun One Application Server throws a ClassCastException when I try to type cast Home object to it's respective interface type.
Here is the code ---
==============================================
Object obj = PortableRemoteObject.narrow( context.lookup( jndiName ), homeClass);
System.out.println("Remote Object - obj : "+obj);
if (obj != null) {
System.out.println("obj.getClass().getName() : "+obj.getClass().getName());
System.out.println("obj.getClass().getSuperclass() : "+obj.getClass().getSuperclass());
Class[] interfaces = obj.getClass().getInterfaces();
if (interfaces != null) {
for (int count = 0; count < interfaces.length; count++) {
System.out.println("interfaces[ " + count + " ].getName() : " + interfaces[ count ].getName());
}==============================================
The class name is dislpayed as the Stub class name.
While displaying the interfaces, the Home Interface name is displayed.
But later when I try to type cast it into Home Interface type, it throws a ClassCastException.
Can somebody please check this?Please post the stack trace. Also, take a look at our EJB FAQ to make sure you're doing the
recommended lookup :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html -
ClassCastException with OracleCallableStatement
Hi,
I am porting our application from WLS6.0 sp2 to WLS6.1 and have encountered the
above error. As far as I can see, nothing in our code has changed (I just rebuilt
against the WLS6.1 libraries and deployed to the new server)
Thanks for any help.
Gino
Stack trace below :
java.sql.SQLException: java.lang.ClassCastException: oracle.jdbc.driver.OracleCallableStatement
at weblogic.jdbc.jts.CallableStatement.clearParameters(CallableStatement.java:220)
at weblogic.jdbc.rmi.internal.CallableStatementImpl.clearParameters(CallableStatementImpl.java:368)
at weblogic.jdbc.rmi.SerialCallableStatement.clearParameters(SerialCallableStatement.java:444)
at com.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToStatement(DaoParameterHelper.java:977)
at com.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToStatement(DaoParameterHelper.java:1170)
at com.banctec.caseware.server.dbaccess.dao.CaseDAOOracle.insertRow(CaseDAOOracle.java:126)
at com.banctec.caseware.server.dbaccess.dao.CaseDAO.insert(CaseDAO.java:190)
at com.banctec.caseware.server.dbaccess.DBAccessBean.insert(DBAccessBean.java:243)
at com.banctec.caseware.server.dbaccess.DBAccessBean_m9wwam_EOImpl.insert(DBAccessBean_m9wwam_EOImpl.java:389)
at com.banctec.caseware.server.casehandler.CaseHandlerBean.createResource(CaseHandlerBean.java:1286)
at com.banctec.caseware.server.casehandler.CaseHandlerBean_nn9cfa_EOImpl.createResource(CaseHandlerBean_nn9cfa_EOImpl.java:475)
at com.banctec.caseware.server.cpc.CPCBean.createResource(CPCBean.java:682)
at com.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl.createResource(CPCBean_1fna_EOImpl.java:387)
at com.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)http://e-docs.bea.com/wls/docs60/notes/issues.html#1024261
Oracle offers several non-standard (not approved by Sun) extensions to JDBC:
OracleConnection
OracleStatement
OracleResultSet
OraclePreparedStatement
OracleCallableStatement
If a user attempts to use these classes within an application that gets its
connection using WebLogic Server JDBC, they will not work.
"Gino Coccia" <[email protected]> wrote in message
news:[email protected]...
>
Hi,
I am porting our application from WLS6.0 sp2 to WLS6.1 and haveencountered the
above error. As far as I can see, nothing in our code has changed (I justrebuilt
against the WLS6.1 libraries and deployed to the new server)
Thanks for any help.
Gino
Stack trace below :
java.sql.SQLException: java.lang.ClassCastException:oracle.jdbc.driver.OracleCallableStatement
atweblogic.jdbc.jts.CallableStatement.clearParameters(CallableStatement.java:2
20)
atweblogic.jdbc.rmi.internal.CallableStatementImpl.clearParameters(CallableSta
tementImpl.java:368)
atweblogic.jdbc.rmi.SerialCallableStatement.clearParameters(SerialCallableStat
ement.java:444)
atcom.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToSta
tement(DaoParameterHelper.java:977)
atcom.banctec.caseware.server.dbaccess.dao.helper.DaoParameterHelper.bindToSta
tement(DaoParameterHelper.java:1170)
atcom.banctec.caseware.server.dbaccess.dao.CaseDAOOracle.insertRow(CaseDAOOrac
le.java:126)
atcom.banctec.caseware.server.dbaccess.dao.CaseDAO.insert(CaseDAO.java:190)
atcom.banctec.caseware.server.dbaccess.DBAccessBean.insert(DBAccessBean.java:2
43)
atcom.banctec.caseware.server.dbaccess.DBAccessBean_m9wwam_EOImpl.insert(DBAcc
essBean_m9wwam_EOImpl.java:389)
atcom.banctec.caseware.server.casehandler.CaseHandlerBean.createResource(CaseH
andlerBean.java:1286)
atcom.banctec.caseware.server.casehandler.CaseHandlerBean_nn9cfa_EOImpl.create
Resource(CaseHandlerBean_nn9cfa_EOImpl.java:475)
atcom.banctec.caseware.server.cpc.CPCBean.createResource(CPCBean.java:682)
atcom.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl.createResource(CPCBean_1
fna_EOImpl.java:387)
atcom.banctec.caseware.server.cpc.CPCBean_1fna_EOImpl_WLSkel.invoke(Unknown
Source)
atweblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:288)
atweblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:93)
atweblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:257)
atweblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:2
2)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) -
How to cast an Object into a specific type (Integer/String) at runtime
Problem:
How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
Example:
public class TestCode {
public static Object func1()
Integer i = new Integer(10); //or String str = new String("abc");
Object temp= i; //or Object temp= str;
return temp;
public static void func2(Integer param1)
//Performing some stuff
public static void main(String args[])
Object obj = func1();
//cast obj into Integer at run time
func2(Integer);
Description:
In example, func1() will be called first which will return an object. Returned object refer to an Integer object or an String object. Now at run time, I want to cast this object to the class its referring to (Integer or String).
For e.g., if returned object is referring to Integer then cast that object into Integer and call func2() by passing Integer object.GDS123 wrote:
Problem:
How to cast an Object into a specific type (Integer/String) at runtime, where type is not known at compile time.
There is only one way to have an object of an unknown type at compile time. That is to create the object's class at runtime using a classloader. Typically a URLClassloader.
Look into
Class.ForName(String) -
CastCastException with OracleCallableStatement
I'm trying to use Oracle JDBC extensions with the Oracle thin Driver (to
read a cursor returned by a PL/SQL function). When I attempt to cast a
CallableStatement to an weblogic.jdbc.vendor.oracle.OracleCallableStatement,
the weblogic wrapper class, I still get the same ClassCastException as if I
try to cast to a vanilla OracleCallableStatement. I thought the weblogic
class was the fix to this problem.
Code is:
ResultSet rs =
((weblogic.jdbc.vendor.oracle.OracleCallableStatement)cs).getCursor(1);
Exception is:
java.sql.SQLException: java.lang.ClassCastException:
oracle.jdbc.driver.OracleCallableStatement
It's interesting that the exception is for
oracle.jdbc.driver.CallableStatement, even though I'm casting to the
Weblogic wrapper class.
Weblogic version is 6.1 sp2
Oracle is 8.1.6
Does anyone know what's happeneng here, and how to fix it.
Any help much appreciated
JohnUnfortunatly, this doesn't work either - it doesn't understand the new type:
java.sql.SQLException: Invalid column type
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
at
oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:53
40)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallab
leStatement.java:245)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallab
leStatement.java:370)
at
weblogic.jdbc.jts.Statement.registerOutParameter(Statement.java:973)
at
weblogic.jdbc.rmi.internal.CallableStatementImpl.registerOutParameter(Callab
leStatementImpl.java:53)
at
weblogic.jdbc.rmi.SerialCallableStatement.registerOutParameter(SerialCallabl
eStatement.java:48)
at com.bluedot.beans.support.ProcedureBuffer.executeFunction(Unknown
Source)
at
com.bluedot.beans.support.ProcedureBuffer.executeTagSetFunction(Unknown
Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean.getExhibitorSt
ats(Unknown Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean_7yjcm7_EOImpl.
getExhibitorStats(EntityManagemen
tServerBean_7yjcm7_EOImpl.java:37)
etc
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
OK. Now it's clear. You can not use OracleTypes.CURSOR.
In order to get a result set from cursor, the right sequence
should be following:
cs.registerOutParameter(1, java.sql.Types.OTHER);
cs.execute();
ResultSet rs = cstmt.getResultSet(1);
Regards,
Slava Imeshev
"John Prout" <[email protected]> wrote in message
news:[email protected]...
Slava
Here's part of the stack trace - the whole thing is probably 100 lines:
java.sql.SQLException: java.lang.ClassCastException:
oracle.jdbc.driver.OracleCallableStatement
at
weblogic.jdbc.jts.CallableStatement.getCursor(CallableStatement.java:277)
at
weblogic.jdbc.rmi.internal.CallableStatementImpl.getCursor(CallableStatement
Impl.java:420)
at
weblogic.jdbc.rmi.SerialCallableStatement.getCursor(SerialCallableStatement.
java:496)
at
com.bluedot.beans.support.ProcedureBuffer.executeTagSetFunction(Unknown
Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean.getExhibitorSt
ats(Unknown Source)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean_7yjcm7_EOImpl.
getExhibitorStats(EntityManagemen
tServerBean_7yjcm7_EOImpl.java:421)
at
com.bluedot.beans.entityManagement.EntityManagementServerBean_7yjcm7_EOImpl_
WLSkel.invoke(Unknown Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
As you can see, the PL/SQL code is being called from an EJB.
The connection is obtained through JNDI:
java.sql.Connection conn = null;
Hashtable ht = new Hashtable() ;
ht.put( Context.INITIAL_CONTEXT_FACTORY ,
"weblogic.jndi.WLInitialContextFactory" );
InitialContext ctx = new InitialContext( ht ) ;
if ( ctx == null ) return null ;
String dataSource = getUserSession().getDatabase() ;
javax.sql.DataSource source = (javax.sql.DataSource) ctx.lookup(
dataSource ) ;
if ( source != null )
conn = source.getConnection() ;
Then the CallableStatement is obtained and used:
OracleConnection con = null ;
OracleCallableStatement cs = null ;
Object returnValue = null;
ResultSet rs = null ;
// String in the form: { ? = call <procedure-name>[<arg1>,<arg2>,...]}
StringBuffer buff = new StringBuffer();
buff.append("{ ? = call ").append(functionName).append("()") ;
// setup mStringBuffer and mStringLength so the rest of the class will
work right
buff.getChars(0, buff.length(),mStringBuffer,0);
mStringLength = buff.length();
con = (OracleConnection)psc.getDatabaseConnection() ;
cs = (OracleCallableStatement)con.prepareCall( buff.toString() ) ;
cs.registerOutParameter(1, OracleTypes.CURSOR);
// printQuery( psc ) ;
boolean result = cs.execute() ; // It's not in the API what "result"
is...
rs =
((weblogic.jdbc.vendor.oracle.OracleCallableStatement)cs).getCursor(1);
The exception happens when I call getCursor(1)
This code works outside weblogic, using a connection I obtain usingstandard
JDBC and the Oracle thin driver.
The sample is extracted from several pieces of the real code, so therecould
be compile errors, etc
John
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
Hi John,
Could you post the questionable code and the full exception?
From information provided it's not clear whether this exception
is thown from the server or from the app.
Regards,
Slava Imeshev
"John Prout" <[email protected]> wrote in message
news:[email protected]...
I am getting a connection from a standard weblogic connection pool,
using
a
JNDI lookup. I can see no way to directly obtain a
weblogic.jdbc.vendor.oracle.OracleConnection. If I cast everything to
the
weblogic OracleConnection and OracleCallableStatement, I still get thesame
ClassCastException
Can you post an example of how to get the
weblogic.jdbc.vendor.oracle.OracleConnection
Thanks
John
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
Hi John,
This exception is thrown because plain oracle connection was used.
To use weblogic oracle extensions, connection should be obtained
from the connection pool, either via DataSource or directly.
Regards,
Slava Imeshev
"John Prout" <[email protected]> wrote in message
news:[email protected]...
I'm trying to use Oracle JDBC extensions with the Oracle thin Driver
(to
read a cursor returned by a PL/SQL function). When I attempt to cast a
CallableStatement to anweblogic.jdbc.vendor.oracle.OracleCallableStatement,
the weblogic wrapper class, I still get the same ClassCastException as
if
I
try to cast to a vanilla OracleCallableStatement. I thought the
weblogic
class was the fix to this problem.
Code is:
ResultSet rs =
((weblogic.jdbc.vendor.oracle.OracleCallableStatement)cs).getCursor(1);
>>>
Exception is:
java.sql.SQLException: java.lang.ClassCastException:
oracle.jdbc.driver.OracleCallableStatement
It's interesting that the exception is for
oracle.jdbc.driver.CallableStatement, even though I'm casting to the
Weblogic wrapper class.
Weblogic version is 6.1 sp2
Oracle is 8.1.6
Does anyone know what's happeneng here, and how to fix it.
Any help much appreciated
John
Maybe you are looking for
-
Problem with continue in a for loop
Hi all I have a variable of type Node[] which contains nodes like Text,ImageView and SVGPath etc... now i want to filter that group which means i want to separate the Text nodes for that i used a for loop as var abc:Node[]; var abcsize=sizeof abc; va
-
Adobe reader crashes when opening, both local and from Firefox
Running Windows XP, Firefox 3.6. Adobe 9.3 crashes Firefox when I attempt to view a downloaded pdf. When I start adobe reader from Windows "Start" it begins to start with Adobe ID screen, then stops with no other effect or error message. Reader 9
-
Create Business Partner from foreing customer
Hi all. I have a problem. When I create a customer by transaction XD01, if customer is Spanish (I'm in Spain), business partner is created automatically, I see this is right in transaction BP. But if I create a foreing customer, business partner isn'
-
Please save my FreeHand :(
My FreeHand 11.0.2 was working fine under 10.5.4 (Intel MacBook), until I installed a security update 2008-005 (at least I suspect that's the reason). After that FreeHand jumps in the dock and nothing happens, a common problem (sigh) the answer to wh
-
Kernel 2.6.20 released !
That's good news ! http://kernel.org Can't wait for the arch package to update.