jsp+tomcat5.0+ms sql 出错了啊!

kite0476 2004-02-09 01:32:03
我用的是tomcat5.0+sql server2000
HTTP Status 500 -

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

type Exception report

message

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

exception

javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.test1_jsp._jspService(test1_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]End of stream was detected on a read.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.test1_jsp._jspService(test1_jsp.java:47)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


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


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

Apache Tomcat/5.0.16

book.sql
use jspdev;
create table book(bookId varchar(50),bookName varchar(50),publisher varchar(100),price float,constraint pk_book primary key(bookId));
insert into book values('001-22-23-1','jsp 应用开发详解','电子工业出版社',59.0);
testmssql.jsp
<%@ page contentType="text/html; charset=gb2312"
language="java" import="java.sql.*, java.io.*"%>
<html>
<body>
以下是从Ms sql server数据库读取的数据:<hr>
<table border=1>
<tr><td width="16">id</td>
<td width="31">书 名</td>
<td width="49">出版社</td><td width="32">价格</td></tr>
<%! String trans(String chi)
{
String result = null;
byte temp [];
try
{
temp=chi.getBytes("iso-8859-1";
result = new String(temp);
}
catch(UnsupportedEncodingException e)
{
System.out.println (e.toString());
}
return result;
}
%>
<%

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver".newInstance();
Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:8080;DatabaseName=jspdev"," a","a";
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery("select * from book;";
while(rst.next())
{
out.println("<tr>";
out.println("<td>"+trans(rst.getString("bookId")+"</td>";
out.println("<td>"+trans(rst.getString("bookName")+"</td>";
out.println("<td>"+trans(rst.getString("publisher")+"</td>";
out.println("<td>"+rst.getFloat("price"+"</td>";
out.println("</tr>";
}
//关闭连接、释放资源
rst.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>


...全文
37 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于 MySQL+Tomcat+Servlet+JSP 的简单作业管理系统源码+数据库+项目说明.zip # HomeworkManagement ## 简介 一个基于 MySQL+Tomcat+Servlet+JSP 的简单作业管理系统 --- ## 更新 ### Ver 5.0 - 所有模块合并至 **web-mvc**,其他模块留作存档 - 拆分 controller 和 service - 使用 lombok 重构 model - 使用 MyBatis 进行数据库连接 ### Ver 4.0 - 实现数据库操作的事务管理 - 添加 AOP 依赖 - 使用 AOP 为所有访问添加日志打印 ### Ver 3.0 - 使用 Spring IoC 管理对象 - 添加 database-mvc module,派生自 database module - web-mvc-context.xml 中添加 component-scan - jdbc 包均使用 @Component 注册为 Bean - 使用 @Autowired 装配对象 - 重构 controller 包,使用 @Autowired 装配对象 - 更新依赖 - web-mvc 对应 database-mvc - web 对应 database - 添加数据库 SQL 转储文件 ### Ver. 2.0 - 添加 web-mvc module - 新 module 使用 spring-webmvc 重构 web module ### Ver. 1.0 在源项目的基础上更新如下: - Maven 项目,用于构建和管理依赖 - Project/Module 模式,一共有三个 Module : - core 用于存放核心代码与工具 - database 用于存放数据库有关代码 - web 用于存放 servlet 和 jsp 有关代码 - 数据库连接部分采用了 Hikari 连接池 ---

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧