求高人鉴定;绝对重赏

zhang_lei21 2011-12-17 11:33:07
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>messagedatabase</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>

<body>
<%
String Name=request.getParameter("Name");
String Information=request.getParameter("Information");
if(Name==null||Information==null|| Name.length()==0||Information.length()==0)
out.println("随便写点东西吧");
Name=new String(Name.getBytes("ISO-8859-1"));
Information=new String(Information.getBytes("ISO-8859-1"));
Statement sql;
Connection con=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:sun","","");
PreparedStatement pstmt=con.prepareStatement("INSERT INTO MESSAGE VALUES(?,?)");
pstmt.setString(1,Name);
pstmt.setString(2,Information);
int i=pstmt.executeUpdate();
if(i==0)
response.sendRedirect("messageboard.jsp");
else
out.print("留言成功");
}
catch(Exception e){
e.printStackTrace();
}finally{
try{
if (con!=null)
con.close();
}catch(Exception e){
e.printStackTrace();
}
}
%>
</body>
</html>
<!--我连接数据库是用windows直接验证的;想问问高人这个数据库的插入有问题么?非常感谢!-->
...全文
35 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

5,655

社区成员

发帖
与我相关
我的任务
社区描述
Web开发应用服务器相关讨论专区
社区管理员
  • 应用服务器社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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