3 Replies Latest reply on Mar 27, 2008 1:14 PM by Vicky Kak

    Using CLOB in Serlvet

    Prasanna Poongavanam Newbie

      Hi All,

      We want to use CLOB in servlet. For this we created Oracle 9i Datasouce in -ds.xml file. But we getting ClassCast Exception while we retreiving the WrappedConnection from Datasource connection.


      DataSource ds = (DataSource) ctx.lookup("java:/OracleDS");
      con = ds.getConnection();//DPDao.getConnection();
      System.out.println("Connection class = " + con.getClass().getName());
      // This returns "$Proxy55"

      // This block is never executed.
      if(con instanceof org.jboss.resource.adapter.jdbc.WrappedConnection){
      WrappedConnection wc=(WrappedConnection)con;
      //with getUnderlying connection method , cast it to Oracle Connection
      Connection oracleConnection=wc.getUnderlyingConnection();
      }


      Basically we getting Proxy connection when we want to retriev the Oracle underlying connection in our servlet code.

      Thanks in advance !
      -PrasP

        • 1. Re: Using CLOB in Serlvet
          Vicky Kak Master

           

          "PrasnnaP" wrote:
          System.out.println("Connection class = " + con.getClass().getName());
          // This returns "$Proxy55"

          No this can not be true , I have tested it right now with oracle .
          Can you try it again with simple jsp page and see if you still see the Proxy , it should be
          WrappedConnection .
          http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAOracleDatasource
          Check this
          How to retrieve the underlying Oracle connection object?
          
           Connection conn = myJBossDatasource.getConnection();
           WrappedConnection wrappedConn = (WrappedConnection)conn;
           Connection underlyingConn = wrappedConn.getUnderlyingConnection();
           OracleConnection oracleConn = (OracleConnection)underlyingConn;
          



          • 2. Re: Using CLOB in Serlvet
            Prasanna Poongavanam Newbie

            Hi Vickyk,

            Thanks for the reply. Even we are not sure why we getting the Proxy connection object in servlet. When we tried the same approach (i,e using DataSource) in EJB we getting the UnderlyingConnection. Can you let us know what exactly you tried to setup the JSP using DataSource.

            What we did:
            1) Created Datasource in -ds.xml file
            2) Used the defined Datasource in our Servlet

            Thanks in advance
            Pras P

            • 3. Re: Using CLOB in Serlvet
              Vicky Kak Master

               

              "PrasnnaP" wrote:
              Can you let us know what exactly you tried to setup the JSP using DataSource.

              I did not try any rocket science there , all I did was this :)
              <%
              InitialContext context = new InitialContext();
              DataSource ds = (DataSource)context.lookup("OracleDS");
              Connection con = ds.getConnection();
              out.println("Connectio is "+con);
              %>


              You need to isolate the problem yourself and get back to us with more concrete evidence ;)