将变量绑定到本机查询时出错。EclipseLink(JPA 2.1)
String sql = "ALTER ROLE ?1 WITH ENCRYPTED PASSWORD 'xxx'"; //(not working)
//String sql = "ALTER ROLE ? WITH ENCRYPTED PASSWORD 'xxx'"; (not working)
Query query = em.createNativeQuery(sql);
String text = txtUsername.getText();
query.setParameter(1, text);
em.getTransaction().begin();
int executeUpdate = query.executeUpdate();
em.getTransaction().commit();
内部异常:org.postgresql.util.PSQLException:错误:“$1”位置或附近的语法错误:12 错误代码:0 线程“AWT-EventQueue-0”中的异常 javax.persistence.PersistenceException:异常 [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):org.eclipse.persistence.exceptions.DatabaseException 调用:ALTER ROLE?WITH ENCRYPTED PASSWORD 'xxx' bind => [1 parameter bound] 查询:DataModifyQuery(sql="ALTER ROLE ? WITH ENCRYPTED PASSWORD 'xxx'") 内部异常:org.postgresql.util.PSQLException:错误:在或附近出现语法错误"$1" 位置:12 错误代码:0 调用:ALTER ROLE ? 使用加密密码“xxx”