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

jsp与数据库连接有关问题

2013-09-11 
jsp与数据库连接问题指点下这是什么原因造成的阿总是没法编译类运行环境是:win2003r2企业版sqlserver2000s

jsp与数据库连接问题
指点下   这是什么原因造成的阿   总是没法编译类
运行环境是:
win2003r2企业版
sqlserver2000   sp4
tomcat6
jdk6

测试能telnet   1433   网页能连接数据库

出错信息如下

HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

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

exception  

org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:574)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root   cause  

java.io.UTFDataFormatException:   Invalid   byte   1   of   1-byte   UTF-8   sequence.
org.apache.jasper.xmlparser.UTF8Reader.invalidByte(UTF8Reader.java:621)
org.apache.jasper.xmlparser.UTF8Reader.read(UTF8Reader.java:492)
org.apache.jasper.xmlparser.XMLEncodingDetector.load(XMLEncodingDetector.java:1007)
org.apache.jasper.xmlparser.XMLEncodingDetector.skipString(XMLEncodingDetector.java:958)
org.apache.jasper.xmlparser.XMLEncodingDetector.scanXMLDecl(XMLEncodingDetector.java:1216)
org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:122)
org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:110)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:308)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:172)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/6.0.10   logs.


--------------------------------------------

Apache   Tomcat/6.0.10


源代码如下

   <%@ page import= "java.lang.*, java.io.*, java.sql.*, java.util.* " contentType= "text/html;charset=gb2312 " %>
   <html>
   <body>
   <% Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
   String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs ";
    String user= "sa ";
   String password= "sa ";
   Connection conn= DriverManager.getConnection(url,user,password);
   Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
   String sql= "select job_id,job_desc from jobs ";


   ResultSet rs=stmt.executeQuery(sql);
   while(rs.next()) { %>
    第一个字段内容为: <%=rs.getString(1)%> <br>
    第二个字段内容为: <%=rs.getString(2)%> <br>
   <% } %>
   <% out.print( "数据库操作成功 "); %>
   <% rs.close();
   stmt.close();
   conn.close();
  %>
   </body>


请指教下   谢谢了,不知道这段小程序错在什么地方了,请大家一并指出

[解决办法]
看上去好像你用了全角的空格在第一行……sigh

www.javaedu.com.cn --- 上海Java培训
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行