aspose file tools
The moose likes Java in General and the fly likes Websphere issue with casting PreparedStatement to Oracle Prepared Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Websphere issue with casting PreparedStatement to Oracle Prepared Statement" Watch "Websphere issue with casting PreparedStatement to Oracle Prepared Statement" New topic
Author

Websphere issue with casting PreparedStatement to Oracle Prepared Statement

Rene Smith
Greenhorn

Joined: Jun 10, 2004
Posts: 21
I have a problem running on Websphere only with casting a PreparedStatement object to an OraclePreparedStatement object. The code I am using is as follows:

int BATCH_SIZE = 2000;
((OraclePreparedStatement)pstatementOra).setExecuteBatch(BATCH_SIZE);

The error I am getting is:
Error updating database.java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement


This code runs on our Apache Tomcat environment

Any help would be appreciated!

Thanks!
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
This would definitely be something I would consider "non portable code". =)

WAS puts a facade layer around the connections pulled from its connection pool in order to properly preserve the connection, state, and operations performed. Hence, the cast in this sense is not possible.

AFAIK, it is not possible to access proprietary properties this way, though you can set custom properties on the datasource configuration.

I would suggest that a bartender move this to the WAS forum...


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by David Hibbs:
This would definitely be something I would consider "non portable code". =)
And yet, sometimes it's necessary.

AFAIK, it is not possible to access proprietary properties this way, though you can set custom properties on the datasource configuration.
If you're lucky, WSJdbcPreparedStatement contains a method to access the underlying PreparedStatement. If you find one, you can use
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Rene,

Welcome to JavaRanch!

We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.

We request display names follow the pattern FIRST_NAME + SPACE + LAST_NAME.

Thanks Pardner! Hope to see you 'round the Ranch!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
patlo siva
Greenhorn

Joined: Nov 08, 2004
Posts: 1
Hi Rene,
I am facing same problem in WSAD 5.0 version. Where as i am trying to get 'wasPs.getPreparedStatement()', but this method is not existed. Could you tell me which version of WSAD you are working on. My problem is i want to get preparedstatement as 'OraclePreparedStatement', Could any body suggets me how to get it. Thanks in advance.

thanks
Siva
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
I found it in WebLogic's PreparedStatement by disassembling it with javap. You might want to do the same to WebSphere's PS class.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Websphere issue with casting PreparedStatement to Oracle Prepared Statement
 
Similar Threads
Oracle and IBM WSAD JDBC issue-HELP!
Using OraclePreparedStatement with IBM WAS
Difference in PreparedStatement and OraclePreparedStatement
Oracle JDBC driver does not support Datatypes defined in java.sql?
Oracle JDBC insert table using WebSphere 5.0