1 Reply Latest reply: Jan 15, 2013 4:14 AM by LukeStudley RSS

    Listprovider Handler OPA 10.2 static DBconnection

    Kunal Sharma
      Hi All,

      If I use ListproviderHandler to connect to database and fetch dropdown values for the control's and declare DbConnect Object as static I can see even when the Handler is called for second time It tries to again reconnect and it forgets the state that It was allready connected to Database. It seems as if ListproviderHandler two programs are running seperately and threading is reffering to two diffrent DBconnect object's If somehow I use JNDI or Connection Pool factory can I be sure that only one connection will be created as most of these classes also use static objects or there will be several DBConnection created?

      Kunal Sharma
      < telephone number removed by moderator >
      (that's bad form - you'll get spam calls for all Eternity)
        • 1. Re: Listprovider Handler OPA 10.2 static DBconnection
          If you let, for instance, JNDI manage the database connection then it (or the pool it comes from) will only be created at startup (usually) depending on your application server.
          In your provider you can create an InitialContext on each request (if required) and it will only point to the original connection pool created.

          Not sure why you would be seeing multiple DB connections created if you had them marked as static - unless there are threading issues in your code or perhaps if you are deploying your plugin using the OPA plugin loading mechanism perhaps there are some class loader issues as it creates new ClassLoaders for each jar in the plugin lib directory - and each class loader would have it's own static instance.