问题解决了,谢谢了! 复制mssql-ds.xml这个文件到server\default\deploy <datasources> <local-tx-datasource> <jndi-name>MSSQLDS</jndi-name> <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=IQTest</connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>sa</user-name> <password>111111</password> <!-- sql to call when connection is created <new-connection-sql>some arbitrary sql</new-connection-sql> --> <!-- sql to call on an existing pooled connection when it is obtained from pool <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql> --> </local-tx-datasource></datasources> 在应用程序中写 InitialContext ic = new InitialContext(); dataSource = (DataSource) ic.lookup(java:/MSSQLDS);就可以了. JBOSS里做连接池挺简单的!
server.xml中最后面在<host></host>中输入
<Context path="/目录名(就是webapps下的你的目录)" docBase="目录名(就是webapps下的你的目录)" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/数据库名" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://ip地址:端口号/数据库名"
username="" password="" maxActive="10" maxIdle="5"
maxWait="10000"/>
</Context>然后在你的服务的WEB-INF的web.xml中要加上<resource-ref>
<description>PostgreSQL DataSource</description>
<res-ref-name>jdbc/数据库名</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
可以试一下
复制mssql-ds.xml这个文件到server\default\deploy
<datasources>
<local-tx-datasource>
<jndi-name>MSSQLDS</jndi-name>
<connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=IQTest</connection-url>
<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
<user-name>sa</user-name>
<password>111111</password>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
--> <!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
--> </local-tx-datasource></datasources>
在应用程序中写
InitialContext ic = new InitialContext();
dataSource = (DataSource) ic.lookup(java:/MSSQLDS);就可以了.
JBOSS里做连接池挺简单的!