Discussions

EJB programming & troubleshooting: connection.close() for entity beans

  1. connection.close() for entity beans (3 messages)

    Hi, This is Harvinder Singh. I have got a doubt regarding connection pooling in WL5.1 for entity beans. Suppose i want to create 20 records (Entity objects) and maximum no of process set in init.ora of oracle8i is set to 15, then I'm getting SQLException: "maximum no of processes exceeded (15) " on the console after geting some of the records which is under limit 15.

    Whats happening is in my ejbCreate() I'm getting a database connection by calling con=ds.getConnection() ds=datasource but i'm not closing it anywhere. So, as a new request comes a new connection object is taken but i want to reuse the earlier connection. Where do i call con.close(), so that as next request comes the previous connection is used OR do i need to set some properties in weblogic.properties file to achieve it.

    Looking forward to your suggestions.

    Regards, Harvinder



  2. connection.close() for entity beans[ Go to top ]

    Get a connection and call close at every method call. So at the beginning of ejbCreate() get a connection and at the end close() it. The call to close() is actually logical and will simply return the connection to the pool. Actually getConnection() is also logical and if all your beans are in the same tx (tx started by session bean) the container will return a reference to the same connection to every bean. If all 20 beans are created in the same tx (creates called from session marked as requires) then you should have only 1 connection open.

    Dave Wolf
    Internet Applications Division
    Sybase
  3. connection.close() for entity beans[ Go to top ]

    Hi Dave,
    Thanks for your reply.

    Regards,
    Harvinder
  4. connection.close() for entity beans[ Go to top ]

    get the connection in a try catch block and close the connection in its finally method , this was the connection will close surely no matter what u do before that.