首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java面试 >

数据库连接池有关问题

2012-01-23 
数据库连接池问题严重: Servlet.service() for servlet jsp threw exceptionorg.apache.jasper.JasperExce

数据库连接池问题
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /index.jsp(3,17) quote symbol expected
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
at org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:198)
at org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:148)
at org.apache.jasper.compiler.Parser.parsePageDirective(Parser.java:309)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:439)
at org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1749)
at org.apache.jasper.compiler.Parser.parse(Parser.java:127)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:120)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:180)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
报错信息。
context 内容 

<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="TestJNDI" type="javax.sql.DataSource" auth="Container"
driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=my"
username="my" password="!@#456..." maxActive="30" maxIdle="30" maxWait="6000"
/>

</Context>

jsp中的引用内容


<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<%@ page import=javax.sql.*" %>
<%@ page import=java.sql.* %>
<%@ page import=javax.naming.* %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

   
-->
  </head>
  
  <body>
  This is my JSP page. <br>
  <%
  try{
  Context ctx=new InitialContext();
  ctx=(Context) ctx.lookup("java:comp/env");


  DataSource ds=(DataSource) ctx.lookup("TestJNDI");
  Connection conn=ds.getConnection();
  Statement stmt=conn.createStatement();
  String sql="select * from user";
  ResultSet rs=stmt.executeQuery(sql);
  while(rs.next()){
  out.println("<br> 用户名: "+rs.getString(2)+"密码 :"+ rs.getString(2));
  }
  rs.close();
  stmt.close();
  conn.close();
  }catch(NamingException e) {
  e.printStackTrace();
  }
  %>
   
   
  </body>
</html>

望高手指点,哪错了。

[解决办法]

探讨
<%@ page import=javax.sql.*" %>

[解决办法]
jsp页面引用,
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /index.jsp(3,17) quote symbol expected

<%@ page import=javax.sql.*" %>

热点排行