lgid是什么类型的?int lgid=2;如果是整型的就可以啊~不过你的SQL应该这么写
String sql="select * from mytable where id="+lglid+"";