【发布时间】:2019-03-20 08:59:43
【问题描述】:
我正在尝试按如下方式执行我的 SQL 语句:
public String get_value(long nodeid,String ts) {
try {
String sql="Select URL FROM urllink WHERE URL="+nodeid;
em.createNativeQuery(sql).executeUpdate();
if (em == null) {
throw new Exception("could not found URL object.");
}
// return 1;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
它会抛出异常消息:
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException:could not execute statement
当我调用 executeUpdate() 时。
我是不是做错了什么?
编辑: 我正在尝试以这种格式传递 URL 参数:
http://126.32.3.11:8080/repository/file/view/viewPDF.jsp?f0=27491&ts=2019.03.20.16.50.58
并使用这些参数检查它们是否存在于列中,如果存在,则运行我的viewPDF.jsp
public String get_value(long nodeid,String ts) {
try {
String sql="Select URL FROM urllink WHERE URL="+"'f0='"+nodeid+"'&ts='"+ts;
em.createNativeQuery(sql).executeUpdate();
if (em == null) {
throw new Exception("could not found URL object.");
}
// return 1;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
【问题讨论】:
标签: java hibernate persistence