2 Replies Latest reply on Aug 19, 2008 3:45 PM by plowmon

    Creating JDBC Datasources/Conn Pools from the cmd line?

    plowmon

      Hi All

      I've been searching the forums, docs, and web and have not been able to find anything to tell me if I can create JDBC datasources/connection pools on JBoss from the command line (maybe using twiddle?). If twiddle is the answer, I am still unsure as to how to proceed. Do I need to create a MBean for each of the objects I see in the MBean browser when I create a datasource via XML:
      DataSourceBinding
      LocalTxCM
      ManagedConnectionFactory
      ManagedConnectionPool

      If I do, is there a guide for twiddle? I have not been able to find any docs for twiddle either.

      I am in need of creating datasources during the test process via ant buildfiles and have a requirement of not having to stop/start the server.

      Thanks
      Jeff

        • 1. Re: Creating JDBC Datasources/Conn Pools from the cmd line?
          peterj

          The best way to create a datasource is to:

          1) Create a *-ds.xml file
          2) Copy/move the file to the deploy directory

          In my build process, I have a generic *-ds.xml file that contains properties for various items. For example:

          <jndi-name>${db.datasource}</jndi-name>
           <connection-url>${db.url.base}${db.database}</connection-url>


          Then in my Ant script, or properties file, I set the db.* properties and I copy the file as follows:

          <copy file="${db.dsxml}"
           tofile="${dir.deploy}/${jboss.server}-${database.type}-ds.xml"
           >
           <filterchain>
           <expandproperties />
           </filterchain>
           </copy>


          My Ant script is set up to allow the MySQL, PostgreSQL or Hypersonic databases. Every aspect of the datasource is configurable from the database name down to the user name and password. I can easily switch from using PostgreSQL to MySQL - it is a one-line properties file change.

          • 2. Re: Creating JDBC Datasources/Conn Pools from the cmd line?
            plowmon

            Thanks! I had tried that before but just realized after reading your post that my second attempt at doing this had an error, I named the file mydatasource-ds2.xml instead of mydatasource2.xml

            :D