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

高分jdbc有关问题

2012-01-18 
高分求助jdbc问题Stringsqlselect*fromdc_userwhere11andnameadminandpassword123rsstmt.executeQ

高分求助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查询别的表的数据

热点排行