日期:2014-05-20  浏览次数:20680 次

高分求助jdbc问题
String   sql   =     "select   *   from   dc_user   where   1=1     and   name   =   'admin '   and   password   =   '123 ' ";
rs   =   stmt.executeQuery(sql);
这样在程序中查,查不出东西来,结果集为空
但是直接在数据库里select   *   from   dc_user   where   1=1     and   name   =   'admin '   and   password   =   '123 ';     却能查出数据  
这是为什么?  
用的是oracle


------解决方案--------------------
如果连上数据库,即使0条记录,返回的rs也不会等于null的


先确定你的Connection能够正确取到
------解决方案--------------------
1、确认一下你程序连接的库和在分析器里执行sql用的库是不是相同
2、rs = stmt.executeQuery(sql);跟踪这一句确认执行时stmt是否为null
3、换sql查询别的表的数据