SQL语句符号问题!!!!谢谢
String sql="insert into UserOpert(UserName,Operation,grade) Values('"Session.getAttribute("UserName")&"','退出系统','"Session.getAttributes("grade")&"')";
提示:
Syntax error on token "Session", delete this token
Session不需要加双引号吗?
[解决办法]
拼装SQL的时候,要注意好其组成的方式,字符串连接用 + 号:
String sql="insert into UserOpert(UserName,Operation,grade) Values('" + Session.getAttribute("UserName") + "','退出系统','" + Session.getAttributes("grade") + "')";
[解决办法]
String sql="insert into UserOpert(UserName,Operation,grade) Values('" + Session.getAttribute("UserName") + "','退出系统'," + Session.getAttributes("grade") + ")";