문제

I'm trying to create a USER (in this case using a H2 database) using JDOQL in DataNucleus

PersistenceManager pm=pmf.getPersistenceManager();
Query query = pm.newQuery("javax.jdo.query.SQL", "CREATE USER GUEST PASSWORD 'abc'");
query.execute();

result: org.h2.jdbc.JdbcSQLException: Method is only allowed for a query. Use execute or executeUpdate instead of executeQuery;

How can i execute this?

Thanks.

도움이 되었습니까?

해결책

Did you try to set the pmf property? datanucleus.query.sql.allowAll=true

Another way you can try is something like that:

JDOConnection con = pm.getDataStoreConnection();
Connection nativeCon = (Connection) con.getNativeConnection();
...
Statement stmt = nativeCon.createStatement();
stmt.executeUpdate("CREATE USER GUEST PASSWORD 'abc'");
...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top