标题:关于JDBC连接池出错
只看楼主
nibuhaoma
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2010-3-29
结帖率:83.33%
 问题点数:0 回复次数:0 
关于JDBC连接池出错
我的JSP采用连接池,在调用连接池时候出现错误,如下错误:

javax.servlet.ServletException: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context



下面是我的连接接代码:

import java.sql.*;
import javax.naming.*;
import javax.sql.DatabaseSource;

public class DBConn{

       public static sychronized Connection getConnection()throws Exception{

                  

                  try{
                  Connection cn=new InitialConnection();
                  Connection dn=(Connection)cn.lookup("java:comp/env");
                  DatabaseSource ds=(DatabaseSource)dn.lookup("jdbc/db_shop");
                  return ds.getConnection();
                      }


                  catch(NamingException e){
                     throws e;
                                          }
                  catch(SQLException e){
                     throws e;
                                       }
 
                                                             }
 
                   }

上面的错误是我在应用在我的JSP网站的时候页面给我提示的错误!!请大家帮我看看,谢谢了!!
搜索更多相关主题的帖子: JDBC 
2010-05-17 19:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-307072-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.259861 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved