精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • Name jdbc is not bound in this Context

    Name jdbc is not bound in this Context
    tomcat的conf\catalina\localhost配置samples.xml
    eclipse的samples工程里名為ConnPool的servlet
    package servlet;
    import java.sql.*;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    /**
    * Servlet implementation class ConnPool
    */
    public class ConnPool extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException {
    // TODO Auto-generated method stub
    response.setContentType("text/html");
    response.setCharacterEncoding("GB2312");
    PrintWriter out=response.getWriter();
    try
    {
    javax.naming.Context ctx=new javax.naming.InitialContext();
    javax.sql.DataSource ds=(javax.sql.DataSource) ctx.lookup("java:/comp/env/jdbc/jdbcdemo");
    Connection conn=ds.getConnection();
    PreparedStatement pstmt=conn.prepareStatement("select * from t_books");
    ResultSet rs=pstmt.executeQuery();
    StringBuilder table=new StringBuilder();
    table.append("");
    table.append("");
    while(rs.next())
    {
    table.append("");
    }
    table.append("
    書名作者
    "+rs.getString("name")+"");
    table.append(rs.getString("author")+"
    ");
    out.println(table.toString());
    pstmt.close();
    }
    catch(Exception e)
    {
    out.println(e.getMessage());
    }
    out.flush();
    out.close();
    }
    }.
    為什么會這樣呢?
    其他人氣:330 ℃時間:2020-02-03 22:57:29
    優(yōu)質(zhì)解答
    在web.xml中配置如下:<resource-ref><res-ref-name>數(shù)據(jù)庫名</res-ref-name><res-type>javax.sql.DataSource</res-type><res-auth>Container</res-auth>{...
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點,以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機版