0 Replies Latest reply on Jul 21, 2005 8:17 AM by vinay purohit

    JBOSS to Oracle Connection Pool Question - Help Needed

    vinay purohit Newbie

      I am trying to migrate an web application from Weblogic to JBOSS 4.0.2 and have got the
      data sources setup.

      In the Weblogic world, I setup the connection pools thru the Weblogic console and then as part
      of my application, I read the db specific props from a property file and a class creates the
      connection for me.


      //Properties File
      app.database.driver=weblogic.jdbc.pool.Driver
      app.database.url=jdbc:weblogic:pool:MyOraclePool
      app.database.property.weblogic.t3.waitForConnection=true
      app.database.property.weblogic.t3.waitSecondsForConnection=5

      //Java Code

      Connection connection = null;
      Driver driver = null;
      String dburl = //load from app properties file
      String driverClassName = //load from app properties file
      Properties dbProperties = //load from app properties file


      // Load the driver.
      try
      {
      Class driverClass = Class.forName(driverClassName);
      driver = (Driver) driverClass.newInstance();
      }
      catch (Exception ex)
      {
      throw new ApplicationException("Failed to load JDBC driver :" + driverClassName, ex);
      }


      try
      {
      connection = driver.connect(dbURL, dbProperties);
      }
      catch (Exception ex)
      {
      throw new ApplicationException("Failed to create a database connection with the specified settings.", ex);
      }


      In the JBOSS world, isnt there any way wherein I can reference the connection pool directly? Is it that I always
      have to get a connection the Datasource way ?




      Connection con = null;
      try
      {

      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("java:/MyOracleDS");

      con = ds.getConnection("username","password");
      }
      catch(Exception ex)
      {
      throw new ApplicationException("Failed to create a database connection with the specified settings.", ex);
      }


      Any replies will be highly appreciated.

      cheers
      Vinay