JSP聊天室踢人

xiangchai 2008-01-05 03:09:33
<%@page contentType="text/html;charset=GBK"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.*" %>

<html>
<head>
<title>用户升级</title>
</head>
<body>
<%

String kickname = request.getParameter("kickname");
String Name =(String) session.getAttribute("USERNAME");
String sDBDriver ="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String sConnStr = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=text";//text表示数据库名称;
Connection Con = null;
Statement Stmt = null;
try /*加载驱动程序*/
{
Class.forName(sDBDriver).newInstance();
}
catch(java.lang.ClassNotFoundException e)
{
out.print("Connect to Database error: " + e.getMessage());
}
try /*建立连接*/
{
Con = DriverManager.getConnection(sConnStr,"sa","");
}
catch(SQLException e)
{
out.print(e.toString());
}
Stmt = Con.createStatement(); /*创建JDBC声明*/
ResultSet rs=null;
String sqlstring = "select * from chatuser where USERNAME = '" + Name + "'";
rs = Stmt.executeQuery(sqlstring);
if(rs.next())
{
int exp= rs.getInt("EXPERIENCE");
if (exp>1000)
{
exp=exp - 50;
Stmt.executeUpdate("update chatuser set EXPERIENCE= +exp where USERNAME = '"+ Name +"'");
Stmt.executeQuery(sqlstring);
out.println("sdsd");
}
else
{
out.println("no");
}
}


%>
</body>
</html>
现在的问题是获得不了参数运行时候出了空白
if(rs.next())
{
int exp= rs.getInt("EXPERIENCE");
if (exp>1000)
{
exp=exp - 50;
Stmt.executeUpdate("update chatuser set EXPERIENCE= +exp where USERNAME = '"+ Name +"'");
Stmt.executeQuery(sqlstring);
out.println("sdsd");
}
这里我不能读取
...全文
34 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xfl123 2008-01-05
  • 打赏
  • 举报
回复
看下能不能传参数

5,657

社区成员

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

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