把deploy目录下的mysql-service.xml文件打开,
结构如下
<server>
  <mbean ...>
  ...
  </mbean>
</server>
改成这种
<server>
  <mbean ...>
  ... // 连接池一
  </mbean>  <mbean ...>
  ... // 连接池二
  </mbean>
</server>想要几个放几个:)
注意连接池的名字要对应好~

解决方案 »

  1.   

    http://www.huihoo.com/middleware/application_server/jboss.html
      

  2.   

    第一个:<!-- appended by tangbr to configure the datasource connecting to bims database. -->
      <mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=BimsMSSQLDS">    <!-- Include a login module configuration named MSSQLDbRealm. 
             Update your login-conf.xml, here is an example for a 
             ConfiguredIdentityLoginModule:    <application-policy name = "MSSQLDbRealm">
           <authentication>
              <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                 <module-option name = "principal">yourprincipal</module-option>
                 <module-option name = "userName">yourusername</module-option>
                 <module-option name = "password">yourpassword</module-option>
                 <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=BimsMSSQLDS</module-option>
              </login-module>
           </authentication>
        </application-policy>    NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the 
          module-option name = "managedConnectionFactoryName"
        must match the object name of the ConnectionManager you are configuring here.
        -->
        <!--uncomment out this line if you are using the MSSQLDbRealm above
        <attribute name="SecurityDomainJndiName">BimsMSSQLDbRealm</attribute>
        -->    <depends optional-attribute-name="ManagedConnectionFactoryName">
          <!--embedded mbean-->
          <mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=BimsMSSQLDS">
            <attribute name="JndiName">BimsDS</attribute>
            <attribute name="ManagedConnectionFactoryProperties">
              <properties>
                <config-property name="ConnectionURL" type="java.lang.String">jdbc:freetds:sqlserver://hp6000server:1433/bims</config-property>
                <config-property name="DriverClass" type="java.lang.String">com.internetcds.jdbc.tds.Driver</config-property>
                <!--set these only if you want only default logins, not through JAAS-->
                <config-property name="UserName" type="java.lang.String">sa</config-property>
                <config-property name="Password" type="java.lang.String"></config-property>
              </properties>
            </attribute>
    <!--Below here are advanced properties -->
            <!--hack-->
            <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends>
          </mbean>
        </depends>
        <depends optional-attribute-name="ManagedConnectionPool">
          <!--embedded mbean-->
          <mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=BimsMSSQLDS">
            <attribute name="MinSize">0</attribute>
            <attribute name="MaxSize">50</attribute>
            <attribute name="BlockingTimeoutMillis">5000</attribute>
            <attribute name="IdleTimeoutMinutes">15</attribute>
            <!--criteria indicates if Subject (from security domain) or app supplied
                parameters (such as from getConnection(user, pw)) are used to distinguish
                connections in the pool. Choices are 
                ByContainerAndApplication (use both), 
                ByContainer (use Subject),
                ByApplication (use app supplied params only),
                ByNothing (all connections are equivalent, usually if adapter supports
                  reauthentication)-->
            <attribute name="Criteria">ByContainer</attribute>
          </mbean>
        </depends>
        <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>    <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</depends>    <attribute name="TransactionManager">java:/TransactionManager</attribute>
        <!--make the rar deploy! hack till better deployment-->
        <depends>jboss.jca:service=RARDeployer</depends>  </mbean>
    <!-- end of appending by tangbr -->
      

  3.   

    第二个:<!-- appended by tangbr to configure the datasource connecting to OnlineDB database. -->
    <!-- use the driver com.microsoft.jdbc.sqlserver.SQLServerDriver supplied by microsoft corporate -->
      <mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=OnlineDBMSSQLDS">
        <!-- Include a login module configuration named MSSQLDbRealm. 
             Update your login-conf.xml, here is an example for a 
             ConfiguredIdentityLoginModule:    <application-policy name = "OnlineDBMSSQLDbRealm">
           <authentication>
              <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                 <module-option name = "principal">yourprincipal</module-option>
                 <module-option name = "userName">yourusername</module-option>
                 <module-option name = "password">yourpassword</module-option>
                 <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=OnlineDBMSSQLDS</module-option>
              </login-module>
           </authentication>
        </application-policy>    NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the 
          module-option name = "managedConnectionFactoryName"
        must match the object name of the ConnectionManager you are configuring here.
        -->
        <!--uncomment out this line if you are using the MSSQLDbRealm above
        <attribute name="SecurityDomainJndiName">OnlineDBMSSQLDbRealm</attribute>
        -->
        <depends optional-attribute-name="ManagedConnectionFactoryName">
          <!--embedded mbean-->
          <mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=OnlineDBMSSQLDS">
            <attribute name="JndiName">OnlineDBDS</attribute>
            <attribute name="ManagedConnectionFactoryProperties">
              <properties>
    <!--
                <config-property name="ConnectionURL" type="java.lang.String">jdbc:freetds:sqlserver://localhost:1433/onlinedb</config-property>
                <config-property name="DriverClass" type="java.lang.String">com.internetcds.jdbc.tds.Driver</config-property>
    -->
                <config-property name="ConnectionURL" type="java.lang.String">jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=OnlineDB</config-property>
                <config-property name="DriverClass" type="java.lang.String">com.microsoft.jdbc.sqlserver.SQLServerDriver</config-property>
                <!--set these only if you want only default logins, not through JAAS-->
                <config-property name="UserName" type="java.lang.String">sa</config-property>
                <config-property name="Password" type="java.lang.String"></config-property>
              </properties>
            </attribute>
    <!--Below here are advanced properties -->
            <!--hack-->
            <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends>
          </mbean>
        </depends>
        <depends optional-attribute-name="ManagedConnectionPool">
          <!--embedded mbean-->
          <mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=OnlineDBMSSQLDS">
            <attribute name="MinSize">0</attribute>
            <attribute name="MaxSize">50</attribute>
            <attribute name="BlockingTimeoutMillis">5000</attribute>
            <attribute name="IdleTimeoutMinutes">15</attribute>
            <!--criteria indicates if Subject (from security domain) or app supplied
                parameters (such as from getConnection(user, pw)) are used to distinguish
                connections in the pool. Choices are 
                ByContainerAndApplication (use both), 
                ByContainer (use Subject),
                ByApplication (use app supplied params only),
                ByNothing (all connections are equivalent, usually if adapter supports
                  reauthentication)-->
            <attribute name="Criteria">ByContainer</attribute>
          </mbean>
        </depends>
        <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>    <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</depends>    <attribute name="TransactionManager">java:/TransactionManager</attribute>
        <!--make the rar deploy! hack till better deployment-->
        <depends>jboss.jca:service=RARDeployer</depends>
      </mbean>
    <!-- end of appending by tangbr -->