ejbSelect with ResultSet return type results in connection leak - Weblogic

This is a discussion on ejbSelect with ResultSet return type results in connection leak - Weblogic ; Hallo all, I noticed connection leaking in the connection pool when the ejbSelect method is used with ResultSet return type. After invoking the method repeatedly (the same number as the number of max connections in pool), I got exception: javax.ejb.FinderException: ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: ejbSelect with ResultSet return type results in connection leak

  1. ejbSelect with ResultSet return type results in connection leak


    Hallo all,

    I noticed connection leaking in the connection pool when the ejbSelect method
    is used with ResultSet return type. After invoking the method repeatedly (the
    same number as the number of max connections in pool), I got exception:
    javax.ejb.FinderException: Couldn't get connection:
    java.sql.SQLException: Cannot obtain connection: driverURL = jdbc:weblogicool:sybase
    production, props = {enableTwoPhaseCommit=true, jdbcTxDataSource=true, connectionPoolID=sybase,
    dataSourceName=tx_sybase}.

    Should the container close the ResultSet when the method invocation is done or
    should I do it by myself (the previous is more logical though)? Does anyone else
    have such problem?

    I am using WLS7.0 sp4 and WLS8.1 sp2 with Sybase ASE 12.5. Both versions of the
    WLS has such behavior.

    Your help will be appreciated,

    Haoguang

  2. Re: ejbSelect with ResultSet return type results in connection leak


    The return type of a ejbSelect() method should be java.util.Collection or java.util.Set


    "Haoguang" wrote:
    >
    >Hallo all,
    >
    >I noticed connection leaking in the connection pool when the ejbSelect
    >method
    >is used with ResultSet return type. After invoking the method repeatedly
    >(the
    >same number as the number of max connections in pool), I got exception:
    >javax.ejb.FinderException: Couldn't get connection:
    >java.sql.SQLException: Cannot obtain connection: driverURL = jdbc:weblogicool:sybase
    >production, props = {enableTwoPhaseCommit=true, jdbcTxDataSource=true,
    >connectionPoolID=sybase,
    >dataSourceName=tx_sybase}.
    >
    >Should the container close the ResultSet when the method invocation is
    >done or
    >should I do it by myself (the previous is more logical though)? Does
    >anyone else
    >have such problem?
    >
    >I am using WLS7.0 sp4 and WLS8.1 sp2 with Sybase ASE 12.5. Both versions
    >of the
    >WLS has such behavior.
    >
    >Your help will be appreciated,
    >
    >Haoguang



  3. Re: ejbSelect with ResultSet return type results in connection leak


    Thanks Slava,

    But, when I try to do getStatement from the ResultSet and then getConnection from
    the statement to close, I got the following:

    java.sql.SQLException: getStatement() is not supported on this RowSet.
    at weblogic.jdbc.rowset.CachedRowSetImpl.getStatement ()Ljava.sql.Statement;(CachedRowSetImpl.java:239)

    It seems the ResultSet that I got is not the raw ResultSet from the ejb-ql (which
    is logical), but a processed row set object from the container. Which implies
    normally the container should do the close for connection, statement and the resultset.
    Then the question is where comes the leak?

    Regards,

    Haoguang


    "Slava Imeshev" wrote:
    >Hi Haoguang,
    >
    >
    >"Haoguang" wrote in message
    >news:3f609923$1@newsgroups.bea.com...
    >> I noticed connection leaking in the connection pool when the ejbSelect

    >method
    >> is used with ResultSet return type. After invoking the method repeatedly

    >(the
    >> same number as the number of max connections in pool), I got exception:
    >> javax.ejb.FinderException: Couldn't get connection:
    >> java.sql.SQLException: Cannot obtain connection: driverURL =

    >jdbc:weblogicool:sybase
    >> production, props = {enableTwoPhaseCommit=true, jdbcTxDataSource=true,

    >connectionPoolID=sybase,
    >> dataSourceName=tx_sybase}.
    >>
    >> Should the container close the ResultSet when the method invocation

    >is
    >done or
    >> should I do it by myself (the previous is more logical though)? Does

    >anyone else
    >> have such problem?
    >>
    >> I am using WLS7.0 sp4 and WLS8.1 sp2 with Sybase ASE 12.5. Both versions

    >of the
    >> WLS has such behavior.

    >
    >
    >You should avoid to let JDBC objects leave boundaries of a method
    >where they are called. Main reason for this is that you want to maintain
    >control over their lifecycle. This said, the best practice is to close
    >open
    >JDBC objects in the same method where they were opened.
    >
    >In your case you would traverse a result set creating a List of value
    >objects
    >to be returned from the method, close Connections, Statements and
    >ResultSets, and return the resulting list to the caller.
    >
    >
    >Hope this helps.
    >
    >Regards,
    >
    >Slava Imeshev
    >
    >



  4. Re: ejbSelect with ResultSet return type results in connection leak


    Thanks, Deepak,

    According to the Bea documentation, ejbSelect can return ResultSet which can contain
    multiple cmp attributes... Not in the spec though, all Weblogic specific.

    Haoguang

    "Deepak Vohra" wrote:
    >
    >The return type of a ejbSelect() method should be java.util.Collection
    >or java.util.Set
    >
    >
    >"Haoguang" wrote:
    >>
    >>Hallo all,
    >>
    >>I noticed connection leaking in the connection pool when the ejbSelect
    >>method
    >>is used with ResultSet return type. After invoking the method repeatedly
    >>(the
    >>same number as the number of max connections in pool), I got exception:
    >>javax.ejb.FinderException: Couldn't get connection:
    >>java.sql.SQLException: Cannot obtain connection: driverURL = jdbc:weblogicool:sybase
    >>production, props = {enableTwoPhaseCommit=true, jdbcTxDataSource=true,
    >>connectionPoolID=sybase,
    >>dataSourceName=tx_sybase}.
    >>
    >>Should the container close the ResultSet when the method invocation

    >is
    >>done or
    >>should I do it by myself (the previous is more logical though)? Does
    >>anyone else
    >>have such problem?
    >>
    >>I am using WLS7.0 sp4 and WLS8.1 sp2 with Sybase ASE 12.5. Both versions
    >>of the
    >>WLS has such behavior.
    >>
    >>Your help will be appreciated,
    >>
    >>Haoguang

    >



  5. Re: ejbSelect with ResultSet return type results in connection leak

    "Haoguang" wrote in message
    news:3f6178b7@newsgroups.bea.com...
    > But, when I try to do getStatement from the ResultSet and then

    getConnection from
    > the statement to close, I got the following:
    >
    > java.sql.SQLException: getStatement() is not supported on this RowSet.
    > at

    weblogic.jdbc.rowset.CachedRowSetImpl.getStatement ()Ljava.sql.Statement;(Cac
    hedRowSetImpl.java:239)
    >
    > It seems the ResultSet that I got is not the raw ResultSet from the ejb-ql

    (which
    > is logical), but a processed row set object from the container. Which

    implies
    > normally the container should do the close for connection, statement and

    the resultset.
    > Then the question is where comes the leak?


    Can you show the code in question?

    Thanks,

    Slava



  6. Re: ejbSelect with ResultSet return type results in connection leak


    Hi, Slava,

    Sorry for the late reply. I did find the cause of this problem: the ejbSelect
    method selects one cmp field and returns a resultset. If I change the return type
    to Collection, then I see no leak. Or if I changed the number of the selected
    cmp fields (> 1), then the leak is also gone. So...
    I did submit a case support to bea with low serverity. Not really sure can call
    it a but...

    Thanks,

    Haoguang

    "Slava Imeshev" wrote:
    >"Haoguang" wrote in message
    >news:3f6178b7@newsgroups.bea.com...
    >> But, when I try to do getStatement from the ResultSet and then

    >getConnection from
    >> the statement to close, I got the following:
    >>
    >> java.sql.SQLException: getStatement() is not supported on this RowSet.
    >> at

    >weblogic.jdbc.rowset.CachedRowSetImpl.getStatement ()Ljava.sql.Statement;(Cac
    >hedRowSetImpl.java:239)
    >>
    >> It seems the ResultSet that I got is not the raw ResultSet from the

    >ejb-ql
    >(which
    >> is logical), but a processed row set object from the container. Which

    >implies
    >> normally the container should do the close for connection, statement

    >and
    >the resultset.
    >> Then the question is where comes the leak?

    >
    >Can you show the code in question?
    >
    >Thanks,
    >
    >Slava
    >
    >



+ Reply to Thread