Discussions

EJB programming & troubleshooting: JDBC connection Pool problem with Weblogic 5

  1. Hi I have written a BMP bean. I compiled all the classes and the xml dd. Then i deployed the bean thru the Deployer Tool. The bean was succesfully deployed. But when trying to run the client, it gives an error message about the database connection .

    Can anyone help me about it. i need to know where to start the trouble shoot at.
  2. Weblogic newsgroup would be better place to ask you question. But anyways, what is the error you are getting? Include your trace.

    --
    Tinou Bao
    www.tinou.com
  3. You wrote a BMP bean (Bean-Managed Persistence). I assume that you must explicitly wrote the persitent logic into the bean class. That means the logic to create, update and remove data associated with an entity. Of course before to do all those tasks you need to call a method getConnection() from a class such as <EntityName>DAO (Data Access Object). This class will handle to get a connection pool to add, update, remove data. Here are the steps you probably need to do to get a pool connection
    1)Create a Connection Pool with a specifi name in weblogic.properties
    2)Instantiate a Properties object instance which includes db user/passowrd
    3) Load a Driver object instance using Class.forName("weblogic.jdbc.pool.Driver"),newInstance()
    4) Invoke the connect()method with parameters: "weblogic:jdbc:pool:<nameConnectionPool>, prop object. This method returns a connection pool object instace

    There are some other ways such as: using DataSource object to get a connection pool

    Hope that helps. More Info go to :http://www.weblogic.com/docs51/classdocs/API_servlet.html#pools0

  4. Hi
    Thanks for replying. I am trying the other methoid now, but i was using the datasource in the code. And here is what i wrote

       private Connection getConnection() throws SQLException {
          try {
            Context jndiCntx = new InitialContext();
            DataSource ds =
                (DataSource)jndiCntx.lookup("java:comp/env/jdbc/myOraclePool");
            return ds.getConnection();
          }
          catch (NamingException ne) {
            throw new EJBException(ne);
          }

    I was calling this getConnection method from all the places to get a connection object.

    Please look at it and let me know whats wrong.

    Thanks for the help once again

    Regards
    Bhupinder
  5. What exception exactly you are getting?That will be helpful to analyze your problem. Would you please send the exception.
  6. From the above snippets, though the actual stack/error trace is missing, let me hazard a solution ...
    1. Check the deployed xml configuration and check if the jndi name for looking up sql datasource is correct(myOraclePool).
    2. Check if the oracle listener is running.

    Meanwhile do post the stack trace so that the problem is clear.
  7. I have a paper that describes how to do this. Check out http://users.bigpond.net.au/stephen.davies/implementingBMP.html
  8. HI
    there
    kindly trace the exception and write for more
    solution.