求助tomcat 6.0数据库连接池配置报错 10
这是获取连接代码publicConnectionGetCon2()throwsNamingException,SQLException{Contextc=newIniti...
这是获取连接代码
public Connection GetCon2() throws NamingException,SQLException{
Context c=new InitialContext();
DataSource ds=(DataSource)c.lookup("java:comp/env/jdbc/test");
return ds.getConnection();
}
web.xml配置
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
context.xml配置
<Resource name="jdbc/test" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databasename=MyLogistics"
username="sa" password="sa" maxActive="20" maxIdle="10"
maxWait="10000" />
报错:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
这是什么原因所致啊? 展开
public Connection GetCon2() throws NamingException,SQLException{
Context c=new InitialContext();
DataSource ds=(DataSource)c.lookup("java:comp/env/jdbc/test");
return ds.getConnection();
}
web.xml配置
<resource-ref>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
context.xml配置
<Resource name="jdbc/test" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost:1433;databasename=MyLogistics"
username="sa" password="sa" maxActive="20" maxIdle="10"
maxWait="10000" />
报错:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
这是什么原因所致啊? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询