4 Replies Latest reply on Sep 21, 2007 10:39 AM by Adrian Brock

    Custom DataSource configuration (instantiation)

    Will Webber Newbie

      Hello all;
      I am trying to configure a custom DataSource in JBoss 4.0.5, and have assumed that this might be possible via configuration info put into a *-ds.xml file. The company I worked for has a corporate development standard that forces developers to use a custom subclass of the OracleConnectionPoolDataSource class. So far, the company has been developing non-ejb Tomcat web apps, where doing what I describe is a cinch {creating custom DataSource pools with a handrolled pool impl}.
      Looking through the JBoss docs, and others areas, I see TONS of examples configuring a DataSource where a JBoss DataSource implementation class will be used (and you are just specifying the Driver for each real connection..) , but none where you specify a different DataSource Impl.
      Judging by the dtd for the *-ds.xml files, it doesn't look possible looking at valid attributes. Is there perhaps another way to pull this off? In theory, if you could do this it might look something like below (note: I an just making this up, it doesn't really work)

      <local-tx-datasource class="myOracleSubClass" >
       <jndi-name>scoobyDo</jndi-name>
       <connection-url>
       jdbc:oracle:thin:mySchema/mySchema@//myPass:1521/myMachine
       </connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
       <min-pool-size>1</min-pool-size>
       <max-pool-size>5</max-pool-size>
      </local-tx-datasource>


      Or maybe.......

      <local-tx-datasource>
       <property name = "class" class="myOracleSubClass"/>
       <property name = "driver" class="oracle.jdbc.driver.OracleDriver"/>
       <property name = "class" class="myOracleSubClass"/>
       <property name = "jndiName" class="scoobyDoo"/>
       <property name = "minConnections" class= "1" />
       ...........
      </local-tx-datasource>




        • 1. Re: Custom DataSource configuration (instantiation)
          Vicky Kak Master

           

          "wwebber" wrote:
          but none where you specify a vendor specific DataSource Impl.

          If you look at the xa-datasource you will find that we specify the vendor specific DataSource implementation , but that is different concept :)
          Now what you have been doing is simply trying to you the pool implementation by different vendor .
          You can create a MBean which would create your custom DataSource and make this available to the Application deployed in Jboss .



          • 2. Re: Custom DataSource configuration (instantiation)
            Will Webber Newbie

            I don't think using the XA configuration will work. The DataSource wrapper we use (thew 'standard' one everyone here is supposed to be using) is not an 'XA" type connection. Also, we use a scheduler called Quartz that requires you to give it a non-transactional (i.e.: 'manual commit') type connection for it to use. My thought so far is that some technique involving firing something up manually using an MBean is what might be a solution. It's tough for me to believe no-one has had the need so far to use their own DataSource implmentation stuff in JBoss.

            • 3. Re: Custom DataSource configuration (instantiation)
              Vicky Kak Master

               

              "wwebber" wrote:
              I don't think using the XA configuration will work. The DataSource wrapper we use (thew 'standard' one everyone here is supposed to be using) is not an 'XA" type connection. Also, we use a scheduler called Quartz that requires you to give it a non-transactional (i.e.: 'manual commit') type connection for it to use. My thought so far is that some technique involving firing something up manually using an MBean is what might be a solution. It's tough for me to believe no-one has had the need so far to use their own DataSource implmentation stuff in JBoss.

              If you so keen to use it in a jboss style which is a JCA way , then you would need to write your own ResourceAdapter and configure the vendor specific DataSource implementation through the conf-property in the connection factory definition xml .
              Have a look at
              http://docs.jboss.org/jbossas/jboss4guide/r5/html/ch7.chapt.html


              • 4. Re: Custom DataSource configuration (instantiation)
                Adrian Brock Master

                 

                "wwebber" wrote:
                It's tough for me to believe no-one has had the need so far to use their own DataSource implmentation stuff in JBoss.


                They have, and it's in the FAQ.

                Tomcat doesn't have JCA, so you can't play that card.
                What you describe is NOT JCA.