打饶大家一会,帮我看看程序
tomcat 连接池的配置,我在conf/conntext.xml中配置如下:
<Resource driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://qpxnet.vicp.net:3341;DatabaseName=Restart"
username="aaa"
password="bbb"
name="jdbc/sqlserver"
type="javax.sql.DataSource"
maxActive="2"
auth="Container"/>然后在我自己的应用的web.xml中配置又如下:
<resource-ref>
<res-ref-name>jdbc/sqlserver</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
最后程序是这样写的:
Connection conn=null;
try{
Context ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env bc/sqlserver");
conn=ds.getConnection();
System.out.println("=======数据库连接成功!!========"+conn);
}catch(Exception e){
}
为什么取不到连接呢??????????先谢各位了
tomcat 连接池的配置,我在conf/conntext.xml中配置如下:
<Resource driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://qpxnet.vicp.net:3341;DatabaseName=Restart"
username="aaa"
password="bbb"
name="jdbc/sqlserver"
type="javax.sql.DataSource"
maxActive="2"
auth="Container"/>然后在我自己的应用的web.xml中配置又如下:
<resource-ref>
<res-ref-name>jdbc/sqlserver</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
最后程序是这样写的:
Connection conn=null;
try{
Context ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env bc/sqlserver");
conn=ds.getConnection();
System.out.println("=======数据库连接成功!!========"+conn);
}catch(Exception e){
}
为什么取不到连接呢??????????先谢各位了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货