context.xml配置如下
<!-- The contents of this file will be loaded for each web application -->
<Context> <!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="jdbc/e-book" auth="Container"
type="javax.sql.DataSource" maxActive="100"
maxIdle="30" maxWait="10000" username="sa"
password="sa"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:microsoft.sqlserver://127.0.0.1:1433;DataBaseName=e-book"
/>
</Context>
web.xml配置如下
<resource-ref>
<description>e-book</description>
<res-ref-name>jdbc/e-book</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>连接类
DataSource source = (DataSource) ic.lookup("java:comp/env/jdbc/e-book");
connection = source.getConnection();
preparedStatement = connection.prepareStatement("select * from titles ORDER by title");
最后提示我Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:microsoft.sqlserver://127.0.0.1:1433;DataBaseName=e-book'用的mssql2005
<!-- The contents of this file will be loaded for each web application -->
<Context> <!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="jdbc/e-book" auth="Container"
type="javax.sql.DataSource" maxActive="100"
maxIdle="30" maxWait="10000" username="sa"
password="sa"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:microsoft.sqlserver://127.0.0.1:1433;DataBaseName=e-book"
/>
</Context>
web.xml配置如下
<resource-ref>
<description>e-book</description>
<res-ref-name>jdbc/e-book</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>连接类
DataSource source = (DataSource) ic.lookup("java:comp/env/jdbc/e-book");
connection = source.getConnection();
preparedStatement = connection.prepareStatement("select * from titles ORDER by title");
最后提示我Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:microsoft.sqlserver://127.0.0.1:1433;DataBaseName=e-book'用的mssql2005
数据库用的mssql2005...还是失败..FML