<mbean code = "org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider">
   <attribute name="Drivers">sun.jdbc.odbc.JdbcOdbcDriver</attribute>
  </mbean>
 
 <mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=SQLServerPool">
   <attribute name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute>
   <attribute name="PoolName">SQLServerPool</attribute>
   <attribute name="URL">jdbc:odbc:myjdbodbc</attribute>
   <attribute name="JDBCUser">sa</attribute>
   <attribute name="Password"/>
   <attribute name="MaxSize">30</attribute>
   <attribute name="GCEnabled">false</attribute>
   <attribute name="InvalidateonError">false</attribute>
   <attribute name="TimestampUsed">false</attribute>
   <attribute name="Blocking">true</attribute>
   <attribute name="GCInterval">120000</attribute>
   <attribute name="IdleTimeout">1800000</attribute>
   <attribute name="IdleTimeoutEnabled">false</attribute>
   <attribute name="LoggingEnabled">false</attribute>
   <attribute name="MaxIdleTimeoutPercent">1.0</attribute>
   <attribute name="MinSize">10</attribute>
 </mbean>

解决方案 »

  1.   

    <attribute name="ManagedConnectionFactoryProperties">
              <properties>
                <config-property name="ConnectionURL" type="java.lang.String">jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDatabase</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"></config-property>
                <config-property name="Password" type="java.lang.String"></config-property>
              </properties>
            </attribute>
      

  2.   

    拷贝 %JBOSS_HOME%\docs\examples\jca\mssql-ds.xml 文件到 %JBOSS_HOME%\server\default\deploy  下面,修改一下该文件即可。
      

  3.   

    Driver和Connection怎么设置呢?
    Driver drv = (Driver) Class.forName(???).newInstance();
    Connection conn = drv.connect(???,null);
      

  4.   

    Driver drv = (Driver) Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance);
    Connection conn = drv.connect(???,null);怎么设??
      

  5.   

    应该不是这样得到,应该有个上下文来取得信息。类似这样吧
    Hashtable ht = new Hashtable();
                ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");  
                Debugger.write("begin connect to database server .....aa.");
                ht.put(Context.PROVIDER_URL,"t3://localhost:8001");
                Context ctx = new InitialContext(ht);    
         
                Debugger.write("please wait ......");
                
                javax.sql.DataSource dataSource1 = (javax.sql.DataSource) ctx.lookup (dataSourceName);
        this.thisConn = dataSource1.getConnection(); 
      
       //this.thisConn.setAutoCommit(false);
       this.thisState =this.thisConn.createStatement();
      

  6.   

    <mbean code = "org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider">
       <attribute name="Drivers">sun.jdbc.odbc.JdbcOdbcDriver</attribute>
      </mbean>
     
     <mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=MS SQL Server">
       <attribute name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute>
       <attribute name="PoolName">MS SQL Server</attribute>
       <attribute name="URL">jdbc:odbc:myjdbodbc</attribute>
       <attribute name="JDBCUser">sa</attribute>
       <attribute name="Password"/>
       <attribute name="MaxSize">30</attribute>
       <attribute name="GCEnabled">false</attribute>
       <attribute name="InvalidateonError">false</attribute>
       <attribute name="TimestampUsed">false</attribute>
       <attribute name="Blocking">true</attribute>
       <attribute name="GCInterval">120000</attribute>
       <attribute name="IdleTimeout">1800000</attribute>
       <attribute name="IdleTimeoutEnabled">false</attribute>
       <attribute name="LoggingEnabled">false</attribute>
       <attribute name="MaxIdleTimeoutPercent">1.0</attribute>
       <attribute name="MinSize">10</attribute>
     </mbean>
      

  7.   

    将Jboss的docs\examples\jca目录下的mssql-ds.xml, mssql-xa-ds.xml文件拷贝至Jboss的server\myself\deploy目录下,修改mssql-ds.xml文件为:(说明:myself是我自己的工作目录,是与default完全相同的目录,只是名字不同,也在server目录下)
        <datasources>
         <local-tx-datasource>
          <jndi-name>mySqlServer</jndi-name>(说明mySqlServer是自己取的jndi名字,你可自己取)
    <connection-url>jdbc:microsoft:sqlserver://192.168.10.2:1433;DatabaseName=database110</connection-url>(说明:ip写对,数据库名字,大小写确认无误)
          <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
          <user-name>sa</user-name>
          <password></password>
         </local-tx-datasource>
    </datasources>
    修改mssql-xa-ds.xml如下:
    <datasources>
      <xa-datasource>
        <jndi-name>MSSQLXADS</jndi-name>
    <xa-datasource-class>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</xa-datasource-class>
        <xa-datasource-property name="ServerName">mayafree</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">database110</xa-datasource-property>(说明:mayafre是我的机器我,database110数据库名)
        <xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
    <!-- not sure if these should be here-->
        <user-name>sa</user-name>
        <password></password>
      </xa-datasource>
    </datasources>
    如果你编写的是cmp,还得修改\jboss\server\myself\conf\standardjbosscmp-jdbc.xml:
    大约在第十二行:
    <jbosscmp-jdbc>
       
       <defaults>
          <datasource>java:/mySqlServer</datasource>
          <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
    datasource是:java:/mySqlServer,其中的mySqlServer就是你前面取的jndi名字。
    datasource-mapping取决于你用的数据库,大约在此文档中的第1619行,你会看到:
          <type-mapping> 
             <name>MS SQLSERVER2000</name> 
    其中的datasource-mapping就是拷贝的此处的name,其它的数据库类同,一定要让
    两者一致。      
      

  8.   

    以上是jdbc的连接配置,其中的username和password要和实际一致。