2 Replies Latest reply on Oct 18, 2002 6:58 AM by dwong

    using up connections?

    hleblanc

      I have a question... if I use the DataSource.getConnection(username, password) method to get a connection, and then close that connection, am I depleting the global pool of connections? Or does getConnection create a new connection instance for the request?
      I'm using this for user validation -- it simplifies certain things for me if my application users are also my Oracle users. Here's the code snippet in question (the ValueSet object contains my jndi context, among other things):

      DataSource source = (DataSource)ValueSet.getInstance().getContext().lookup("java:/TestDB");
      connection = source.getConnection(username,password);
      /* ... other stuff happens here, then... */
      connection.close();

      Is this bad practice? I've been experiencing very intermittent errors where jboss tells me there are no ManagedConnections available. Then I bounce jboss, and the problems go away... for a few days.
      What happens if I just let the connection be garbage-collected? I don't want the app to use this user-specific connection; it's just for login purposes, and a different user account actually has the rights to retrieve the data.
      Not a burning issue, but it would be nice to know.
      Thanks,
      H

        • 1. Re: using up connections?
          davidjencks

          Well, I don't recommend this. I think the minimum time before a connection is discarded due to timeout is 1 minute, so you have an opportunity to use up a really lot of connections.

          I assume from your "no managed cx available" message you are using a jboss 3+ version. I'm surprised you're running out of connections since the max is per user. Perhaps you are running out on the pool that actually has connections that do the work?

          • 2. Re: using up connections?
            dwong

            David, I faced running out connection (getting from the pool). The case is that for each call to a CMP bean, a new connection is created (from v$session in oracle), and that connection is marked INACTIVE. However, it wasn't cleaned for a long while (e.g. one day). You say 1 min., how to set it ? I am using JBoss 3.0.3 and Oracle8i, with oracle-service.xml.

            Dwong