67,513
社区成员
发帖
与我相关
我的任务
分享
<Resource
name="jdbc/sqlserver"
auth="Container"
type="javax.sql.DataSource"
maxActive="50"
maxIdle="30"
maxWait="10000"
logAbandoned="true"
username="sa"
password="SQL2005"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;databasename=blog"/>
<description>DBConnection</description>
<res-ref-name>jdbc/sqlserver</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
然后是使用:Context ctx = new InitialContext();
//获取连接池对象
DataSource dSource = (DataSource) ctx.lookup("java:comp/env/jdbc/sqlserver");
con = dSource.getConnection();
出错是DataSource dSource = (DataSource) ctx.lookup("java:comp/env/jdbc/sqlserver");