0

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.

marcolopes
  • 9,232
  • 14
  • 54
  • 65

1 Answers1

3

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'");
...
engilyin
  • 1,011
  • 9
  • 22
  • Yes, i have the "datanucleus.query.sql.allowAll=true". Your answer is the only option that could really work. Thanks. – marcolopes Nov 09 '12 at 16:18