JSP聊天室踢人
<%@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");
}
这里我不能读取