当前位置: 代码迷 >> Java Web开发 >> 求教“javax.naming.NameNotFoundException: Name is not bound in this Context”,该怎么解决
  详细解决方案

求教“javax.naming.NameNotFoundException: Name is not bound in this Context”,该怎么解决

热度:802   发布时间:2016-04-12 22:39:17.0
求教“javax.naming.NameNotFoundException: Name is not bound in this Context”
请大家指出错误谢谢~控制台报错为“avax.naming.NameNotFoundException: Name  is not bound in this Context”


package com.ncs.util;
import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;
 
public class util {
    public static Connection getPoolConnection() throws Exception{
       Context ctx=new InitialContext();
       DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/StrutsTestPool");
       Connection conn=ds.getConnection();
       return conn;
    }
}
 
 
<?xml version="1.0" encoding="UTF-8"?>
<context>
    <Resourse

       auth="Container"
       name="jdbc/StrutsTestPool"
       type="javax.sql.DataSourse"
       driverClassName="oracle.jdbc.driver.OracleDriver"
       url="jdbc:oracle:thin:@192.168.81.94:1521:uatdb2"
       username="oscusr2"
       password="password"
    />
</context>
              

------解决方案--------------------
数据源找不到
------解决方案--------------------
这个错是很有可能这个名称
java:comp/env/jdbc/StrutsTestPool
所映射的实际资源找不到才报的,因为看名称貌似没啥错

javax.sql.DataSourse
Sourse是不是拼错了,应该是Source

参考处:
http://wenku.baidu.com/view/0ad7d94a852458fb770b5602.html
http://blog.csdn.net/itwit/article/details/7027834

  相关解决方案