首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

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

2012-01-11 
jsp语句中的变量如何添加和+号?select*fromusertablewhereusercode usernameandactiveflagy其中userna

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是整形

热点排行