日期:2014-05-20  浏览次数:20692 次

NetBeans数据库连接池的问题...搞了半天了,请高手指教!
我已经按照这篇文章中的要求http://blog.csdn.net/java060515/archive/2007/06/19/1658316.aspx
在我的NETBEANS捆绑的TOMCAT上配置了MYSQL数据库,并且配置了WEB.XML,和CONTENT.XML,但是我写了如下程序,仍然报错...
实在找不出来了...

<%@page   contentType= "text/html "%>
<%@page   pageEncoding= "gbk "%>
<%@   page   import= "java.sql.*,javax.sql.*,javax.naming.* "   %>
<html> <head> <title> 注册用户 </title> </head>
<body>
               
            <%  
                request.setCharacterEncoding( "gb2312 ");
                String   username=request.getParameter( "username ");
                String   password=request.getParameter( "password ");
                String   password2=request.getParameter( "password2 ");
                String   myclass=request.getParameter( "class ");
                if(null==username||null==password||null==myclass||null==password2){
                        out.println( "你有项目未填! ");
                        out.println( "请点击 <a   href=\ "register.html\ "> 返回 <\\a> 重新填写 ");
                }
                Context   ctx=new   InitialContext();
                DataSource   ds=(DataSource)   ctx.lookup( "java:comp/env/jdbc/connectionPool ");
                Connection   conn=ds.getConnection();
                PreparedStatement   pstmt=conn.prepareStatement(
                                "insert   into   userinfo(username,password,major)values( "   +
                                "?,?,?) ");
                pstmt.setString(1,username);
                pstmt.setString(2,password);
                pstmt.setString(3,myclass);
                pstmt.executeUpdate();
                pstmt.close();
                conn.close();
               
                %>
        </body>
</html>
程序有错吗?还是配置有问题呢
报错如下:
type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   Name   connectionPool   is   not   bound   in   this   Context