Oracle大师进:JDBC连接Oracle查不到数据
发布网友
发布时间:2022-04-07 16:22
我来回答
共3个回答
热心网友
时间:2022-04-07 17:52
// 尝试把单引号具体的值分隔开来试试。
String sql="select * from msg_in t where req_or_res =0 and sip_uuid='"+"3c7e4339-c45e-4508-bf32-92beb3dd7233+"'";
preparestamet.executeQuery(sql);
另外,根据你的描述在PL/SQL上可以正常运行并得到结果,那就说明这条SQL语句是没有问题的。此时你应该检查JAVA语法的问题,或者说写法是否正确。
追问我确认不是语法问题,因为我把req_or_res换成表内其他字段,就没问题了,唯独是req_or_res这个字段加其他字段就不行了。
追答有没有尝试过req_or_res这个字段直接在PL/SQL里查询是否有问题?
热心网友
时间:2022-04-07 19:10
确定:select * from msg_in t where req_or_res =0 and sip_uuid='3c7e4339-c45e-4508-bf32-92beb3dd7233' 能在PL/SQL里面查询到数据
把sql 写成动态的:
public list select(int req_or_res,String sip_uuid){
String sql="select * from msg_in t where req_or_res ="+req_or_res+" and sip_uuid="+sip_uuid+"";
}
或
public list select(){
int req_or_res=0;
String sip_uuid="3c7e4339-c45e-4508-bf32-92beb3dd7233";
String sql="select * from msg_in t where req_or_res ="+req_or_res+" and sip_uuid="+sip_uuid+"";
}
热心网友
时间:2022-04-07 20:44
select * from msg_in t where req_or_res =0 and sip_uuid='3c7e4339-c45e-4508-bf32-92beb3dd7233'
把上面的字段名修改成大写的试试
select * from MSG_IN t where REQ_OR_RES=0 and SIP_UUID='3c7e4339-c45e-4508-bf32-92beb3dd7233'追问不行。这跟大小写关系不大,我现在就怀疑是req_or_res这个字段有问题。
追答你这个字段是字符窜类型还是数字类型?