4 Replies Latest reply on Aug 19, 2002 11:45 AM by rbnb

    Oracle XMLType argh !

    rbnb

      Hi:

      I am running JBoss 2.4.4, and am connecting to Oracle 9i. One of the tables I am using has a column XMLType. When I don't use JBoss's JDBC Data Source I connect, write etc... without a problem. Once I switch to using JBoss's JDBC Datasource my code dies. I get a class cast exception, on my insert.

      As I said before, with out a JDBC DS I can insert fine. For performance reasons I would like to be able to use the connection pooling of JBoss.
      I rewrote the code to utilize CLOB's and with or without a DS I can inset no problem.

      Am I doing something wrong? I was wondering is there support for XMLType.

      We are eventually going to move to JBoss 3.0, but that is not an option right now.

      any help is appreciated

      Rob

        • 1. Re: Oracle XMLType argh !
          davidjencks

          You don't give many details... but I'd guess you need the Oracle connection class itself to use the xml types?

          You can get the Oracle connection by calling con.getUnderlyingConnection(). Be careful though, closing it for instance will have disasterous results on the pooling.

          • 2. Re: Oracle XMLType argh !
            rbnb

            Hi David:

            Thank you for your help. I have located the getUndelyingConnection method in the ConnectionInPool class, forgive me here.... but how do I get access to the "ConnecitonInPool" class. Sorry about being vague before, I should have told you it was a class cast exception, you were on the ball though with your assumption. I just didn’t want my first post to be a mammoth one with errors an code. Here is the snippet of code that currently blows with the pool,

            //connection passed in and used here:

            XMLType xmltype = new XMLType.createXML(conn, xmlDoc);
            ...
            pst.setObject(1, xmlType);
            //where xmlDoc is my document//
            dies because conneciton is in fact a pooled connection

            what I hope for:

            OracleConnection oconn = (OracleConnection)**get underlying connection**
            XMLType xmltype = new XMLType.createXML(oconn, xmlDoc)
            ...
            pst.setObject(1, xmlType);

            so I guess my question is how to get the underlying connection....
            your help is much appreciated.

            Rob

            • 3. Re: Oracle XMLType argh !
              davidjencks

              Doesn't
              Connection c = ds.getConnection();
              OracleCon oc = (OracleCon)((ConnectionInPool)c).getUnderlyingConnection();

              work?

              • 4. Re: Oracle XMLType argh !
                rbnb

                Got it... ...(I was screwing up my casting) this is what works...

                OracleConnection c = (OracleConnection)((ConnectionInPool)conn).getUnderlyingConnection();

                XMLType xt = XMLType.createXML(c, content);

                Thank you again.

                Rob