Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 求助(在写入数据库的时候出错!)
c00lzhang





发贴: 20
于 2005-11-09 11:41 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>²åÈëÊý¾Ý</title>
</head>
<body>
<%! String ID,Name,Sex,Age,bumen,url,sql;%>
<%! int i;%>
<%! Connection conn;%>
<%! ResultSet rs;%>
<%! Statement stmt;%>
<%
ID=request.getParameter("ID");
Name=request.getParameter("Name");
Name=new String(Name.getBytes("ISO-8859-1"));
Sex=request.getParameter("Sex");
Sex=new String(Sex.getBytes("ISO-8859-1"));
Age=request.getParameter("Age");
bumen=request.getParameter("bumen");
bumen=new String(bumen.getBytes("ISO-8859-1"));
if(ID.length()!=4)
{
response.sendRedirect("err.jsp");
}
if(Name.equals(""))
{
response.sendRedirect("err.jsp");
}
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=gongsi";
conn=DriverManager.getConnection(url,"admin","123456");
stmt=conn.createStatement();
sql="select * from renyuan where ID='"+ID+"'";
rs=stmt.executeQuery(sql);
if(rs.getRow()>0)
  {
response.sendRedirect("err.jsp");
}
sql="insert into renyuan(ID,Name,Sex,Age)";
sql=sql+"values('"+ID+"','"+Name+"','"+Sex+"','"+Age+"','"+i+"')";
stmt.executeUpdate(sql);
out.println("<font size=3 color=blue>ÕýÔÚ´¦ÀíÐÅÏ¢£¬ÇëÉÔºó......</font><meta http-equiv='refresh' content='2;url=list.jsp'>");
rs.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
response.sendRedirect("err.jsp");
}
%>
</body>
</html>
报出的错误是我给的err.jsp但我输入的数据应该没有错




一个程序员的奋斗历程

话题树型展开
人气 标题 作者 字数 发贴时间
2251 求助(在写入数据库的时候出错!) c00lzhang 1756 2005-11-09 11:41
1885 Re:求助(在写入数据库的时候出错!) c00lzhang 24 2005-11-09 14:14
1875 Re:求助(在写入数据库的时候出错!) ntshenwh 39 2005-11-14 21:51
1896 Re:求助(在写入数据库的时候出错!) c00lzhang 45 2005-11-15 08:59

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923