当前位置: 代码迷 >> Java Web开发 >> 关于JDBC连接池出错
  详细解决方案

关于JDBC连接池出错

热度:414   发布时间:2010-05-17 19:54:44.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  

----------------解决方案--------------------------------------------------------
  相关解决方案