server.xml:
<Resource
name="jdbc/webdb"
type="javax.sql.DataSource"
password="oamanager"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="2"
maxWait="5000"
username="sa"
url="jdbc:microsoft:sqlserver://115.88.14.6:1433/webdb"
maxActive="4"/>
context.xml:
<ResourceLink name="jdbc/webdb" global="jdbc/webdb" type="javax.sql.DataSource"/>
web.xml:
<resource-ref>
<res-ref-name>jdbc/webdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
jsp:
<%
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/webdb");
Connection con = ds.getConnection();
out.print("success");
} catch (Exception ex) {
out.print("exception:"+ex.getMessage());
}
%>
报错:
exception:Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.) 请问哪里错了?
<Resource
name="jdbc/webdb"
type="javax.sql.DataSource"
password="oamanager"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="2"
maxWait="5000"
username="sa"
url="jdbc:microsoft:sqlserver://115.88.14.6:1433/webdb"
maxActive="4"/>
context.xml:
<ResourceLink name="jdbc/webdb" global="jdbc/webdb" type="javax.sql.DataSource"/>
web.xml:
<resource-ref>
<res-ref-name>jdbc/webdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
jsp:
<%
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/webdb");
Connection con = ds.getConnection();
out.print("success");
} catch (Exception ex) {
out.print("exception:"+ex.getMessage());
}
%>
报错:
exception:Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.) 请问哪里错了?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货