List<Atl> atls = commonDao.findByQuery("from Atl a where a.code ="+code);
报错:ORA-01722: 无效数字
List<Atl> atls = commonDao.findByQuery("from Atl a where a.code <>null");
通过。
List<Atl> atls = commonDao.findByQuery("from Atl a where a.code =:code",
new String[]{"code"},new Object[]{code});
这种写法不会报错,通过
解决:1,code的隐式转换
2,nvl( ) 函数 从两个表达式返回一个非 null 值。 NVL(n1,n2) ,若n1为null,则返回n2,若n1不为null,则返回n1
返回值类型
字符型、日期型、日期时间型、数值型、货币型、逻辑型或 null 值
本文介绍了在使用Java操作Oracle数据库时遇到的SQL注入问题及解决方案。通过对比不同查询语句的编写方式,详细解释了如何避免因代码直接拼接导致的ORA-01722错误,并推荐使用参数化查询来增强代码的安全性和稳定性。
1564

被折叠的 条评论
为什么被折叠?



