读书人

jsp语句中的变量怎么添加和+号

发布时间: 2012-01-11 22:28:46 作者: rapoo

jsp语句中的变量如何添加''和+号?
select * from usertable where usercode= 'username ' and activeflag=y
其中username是从页面中取值的变量

[解决办法]
String str= "select * from usertable where usercode= ' "+username+ " ' and activeflag= 'y ' ";
ResultSet rs=stmt.executeQuery(str);
activeflag=y 是sql变量还是其它?
[解决办法]
俺来教你。
首先坐好
比如这一句
String sql== "select * from usertable where usercode= ' "+username+ " ' and activeflag=y "
out.println(sql);去掉左右两边的双引号放到数据中去查一下就知道对错了

一般username是数据库中的字段是字符串类型,y是整形

读书人网 >Java Web开发

热点推荐