为什么会出现"无效字符"错误!oracle

jbas 2004-12-13 04:22:42
我在sqlplus上可以执行这个语句的,结果为0,但当我有jdbc调用,写在javabean中时,出现"无效字符"错误!
public int getResponsNumberByPkey(String pkey){
int responseNumber=0;
String sql="select count(*) as num from TWORKITEMPERSON a";
sql=sql+" where a.personKey="+pkey+" and a.workstat=1 and exists(select 1 from TWORKITEM where workitemkey=a.workitemkey and state<>(select PKey from TSTATE where Label='close'));";
System.out.println(sql);
try {
java.sql.ResultSet rs=dbPoll.executeQuery(sql);
if(rs.next()){
responseNumber=rs.getInt("num");
}
} catch (SQLException e) {
System.out.println(e);
}finally{
dbPoll.close();
}
return responseNumber;
}
...全文
206 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jbas 2004-12-15
  • 打赏
  • 举报
回复
多了一个;
AHUA1001 2004-12-15
  • 打赏
  • 举报
回复
肯定是sql语句转换成java的String时出的错误。
PKey from TSTATE where Label='close'));";
分号多不多?
EverythingMaster 2004-12-13
  • 打赏
  • 举报
回复
这是一个bug
tom2005 2004-12-13
  • 打赏
  • 举报
回复
select 1
1为列名吗
fmzbj 2004-12-13
  • 打赏
  • 举报
回复
帮你顶!
jbas 2004-12-13
  • 打赏
  • 举报
回复
workstat是number类型的,还是同样的错误。
tom2005 2004-12-13
  • 打赏
  • 举报
回复
up
AHUA1001 2004-12-13
  • 打赏
  • 举报
回复
sql=sql+" where a.personKey="+pkey+" and a.workstat=1 and exists
workstat是什么类型的,把1加上引号试试。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧