<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>
<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>
<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>
Driver drv = (Driver) Class.forName(???).newInstance();
Connection conn = drv.connect(???,null);
Connection conn = drv.connect(???,null);怎么设??
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();
<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>
<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,其它的数据库类同,一定要让
两者一致。