1、原本java插入数据库表数据写法是这样的
String sql = "INSERT INTO AAA (id1,id2,id3,id4) VALUES ('1','2','3','4'); "; baseDao.exexuteBySql(sql);
2、调用的baseDao.exexuteBySql方法是这样的
public int exexuteBySql(String sql) throws Exception { try { log.debug("sql:{}", sql); SQLQuery query = null; Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession(); query = session.createSQLQuery(sql); return query.executeUpdate(); } catch (RuntimeException re) { log.error("exexuteBySql(String sql) ", re); throw re; } }
3、我的数据库是oracle11g的,结果在执行的时候,报错ORA-00911: 无效字符
4、去掉sql末尾的;号就可以了
String sql = "INSERT INTO AAA (id1,id2,id3,id4) VALUES ('1','2','3','4') "; baseDao.exexuteBySql(sql);
如对本文有疑问, 点击进行留言回复!!
springmvc之ResponseBody响应json数据遇到的错误及解决
uni-app 后台升级 静默升级 uniapp 后台更新 静默更新 在线升级
SpringBoot多Module启动报错Could not transfer metadata
Hibernate项目报错:Cannot call sendError() after the response has been committed
网友评论