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

奇怪的conn.prepareStatement问题
conn.prepareStatement(sqlStr,java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
这条语句里的sqlStr 如果是 select user_id from tuser where user_name=? 正常
但一定用了聚合函数就报空指针错误 比如 select max(user_id) from tuser where user_name=? 
问下大家遇到过这样的情况吗,该怎么解决,100分送上

------解决方案--------------------
--->select max(user_id) from tuser where user_name=? 
改成select max(user_id) from tuser where user_name=? group by user_name

------解决方案--------------------
select max(user_id) from tuser where user_name=? group by user_name 
语句应该没问题,你可以用到数据库中测试下,但空指针问题,我想应该是其它的问题,没取到值或某个值为空,能不能多贴点代码出来,最好把异常也贴出
------解决方案--------------------
conn.prepareStatement(sqlStr);这样呢?
------解决方案--------------------
group by DEPT_NAME ,pname -->group by a.DEPT_NAME,a.pname
------解决方案--------------------
包是不是有问题呀
------解决方案--------------------
嗯,驱动jar?