日期:2014-05-16 浏览次数:20660 次
在工作中需要用到查询语句:
String userName = name; System.out.println("loginName:"+name); System.out.println("password:"+password); List<User> list = new ArrayList<User>(); list = new ArrayList<User>(); con = new DBUtlie().getConnection(); String sql = "select * from s_user where loginName = '"+userName+"'"; ps = con.prepareStatement(sql); rs = ps.executeQuery();
String sql = "select * from s_user where loginName = userName;结果报错,说找不到列userName.我想不是让你找userName列啊,userName是我自己的定义的变量。原来,需要在user外加双层双引号,才可以。