标题:[求助] 用jsp 连接 sql server 2ooo 报错
只看楼主
luyeli
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-10-31
 问题点数:0 回复次数:4 
[求助] 用jsp 连接 sql server 2ooo 报错

用jsp 连接 sql server 2ooo 报错如下:
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.xianfeng.index_jsp._jspService(index_jsp.java:205)
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
我写的代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*"%>
<%

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();

String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=my";

String user="sa";

String password="123";

Connection conn= DriverManager.getConnection(url,user,password);

Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs;
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
GregorianCalendar timenow=new GregorianCalendar();
int year;
int month;
int day;
int hour;
int min;
int sec;
year=timenow.get(Calendar.YEAR);
month=timenow.get(Calendar.MONTH)+1;
day=timenow.get(Calendar.DAY_OF_MONTH);
min=timenow.get(Calendar.MINUTE);
sec=timenow.get(Calendar.SECOND);
hour=timenow.get(Calendar.HOUR);
request.setCharacterEncoding("gb2312");
String s=""+year+"-"+month+"-"+day+" "+hour+":"+min+":"+sec;
String title=request.getParameter("title");
String author=request.getParameter("author");
String source=request.getParameter("source");
String content=request.getParameter("content");
String type=request.getParameter("type");
String radiobutton=request.getParameter("radiobutton");
String sql="select * from news";
int i=0;
rs=stmt.executeQuery(sql);
while(rs.next()){
i=i+1;
}
i=i+1;
String sql1="INSERT INTO news(newid,title,content,author,source,datetime,newtype,isimportant) values('"+i+"','"+title+"','"+content+"','"+author+"','"+source+"','"+s+"','"+type+"','"+radiobutton+"')";

stmt.execute(sql1);

response.sendRedirect("index.jsp");
%>
</body>
</html>

搜索更多相关主题的帖子: jsp sql server 
2006-10-31 22:39
luyeli
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-10-31
得分:0 

高手们帮我看看啊,谢谢了!

2006-10-31 22:40
luyeli
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-10-31
得分:0 
sp3 补丁我打了,JDBC 也装了啊,权限好像没有问题啊,不知道怎么回事啊!
2006-10-31 22:46
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
端口是不是错了

可惜不是你,陪我到最后
2006-11-01 09:48
luyeli
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-10-31
得分:0 
后来我在安全性军窗口中把windowns登录改为windowns和sql server身份登录就可以了!真不容易啊!终于解决了!
2006-11-02 18:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-100026-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.073702 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved