报错为:javax.naming.NamingException: Cannot create resource instance
我用的是tomcat是6.0.26,mysql为5.1
在META-INF下的context.xml
<Context>
<Resource name="jdbc/bookstore" auth="Container" type="javax.sql.DateSource"
maxActive="10" maxIdle="10" maxWait="10000"
username="root" password="liumeng" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bookstore?autoReconnect= true"/>
</Context>我把项目放在了webapp下了。
搜了搜,有人让配web.xml 加了句
<resource-ref>
<res-ref-name>BookStore</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>不过还是没有用
public class BookDBBean implements Serializable{ /**
*
*/
private DataSource ds=null;
public BookDBBean() throws NamingException{
Context ct= new InitialContext();
ds=(DataSource) ct.lookup("java:comp/env/jdbc/bookstore");
}不知哪位大虾有空给点拨一下吧,实在没招了。
我用的是tomcat是6.0.26,mysql为5.1
在META-INF下的context.xml
<Context>
<Resource name="jdbc/bookstore" auth="Container" type="javax.sql.DateSource"
maxActive="10" maxIdle="10" maxWait="10000"
username="root" password="liumeng" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bookstore?autoReconnect= true"/>
</Context>我把项目放在了webapp下了。
搜了搜,有人让配web.xml 加了句
<resource-ref>
<res-ref-name>BookStore</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>不过还是没有用
public class BookDBBean implements Serializable{ /**
*
*/
private DataSource ds=null;
public BookDBBean() throws NamingException{
Context ct= new InitialContext();
ds=(DataSource) ct.lookup("java:comp/env/jdbc/bookstore");
}不知哪位大虾有空给点拨一下吧,实在没招了。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货