Skip to Content
avatar image
Former Member

How do I get an OraclePreparedStatement from a DataSource?

I'm trying to parse XML data types from an Oracle 10g database. The Oracle recommended way of doing this is as follows:

Connection conn = ....
OraclePreparedStatement stmt = (OraclePreparedStatement)conn.prepareStatement( "..." );
OracleResultSet rs = (OracleResultSet)stmt.execute();
while( ) {
	OPAQUE opaque = rs.getOPAQUE(1);
	XMLType xml = opaque.createXML( opaque );

and then you go from there. This all works great when I manually create the connection using the non-j2ee method of directly connecting to the database using the jdbc:oracle:thin driver. However, when I try to allocate a connection using the J2EE defined data source, I can't do the above since the classes returned to me are SAP types, and don't take kindly to being cast to Oracle types.

Is there a way to do this? I've done some digging, but I haven't found the end of the tunnel yet 😊 I can always connect directly to the database, but I would rather use the data source management service of the J2EE engine.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jan 27, 2006 at 02:38 PM

    Hi Ken,

    Why don't you specify the same parameter in the connection along with the Oracle driver in the J2EE connection pool. I hope you are doing that.

    In that case J2ee engine will manage the connections but the connections that you will get will be created from the oracle driver and hence now you will have oraclepreparedstatements.

    Hope this helps.


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Ken,

      I am having kind of the same issue you have, I get a ClassCastException with this

      OracleDataSource ods = (OracleDataSource)(new InitialContext()).lookup("jdbc/<DATASOURCENAME>");

      I created an abstract portal componente in a portal application, I added the dpool.jar and copy classes12.jar in the lib folder of the project, added the including xdb.jar and xmlparserv2.jar to the datasource in VA but I keep getting the ClassCastException. Any suggestions?