![]() |
![]() |
|
| Index | Recent Threads | Unanswered Threads | Who's Online | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 2
|
|
| Author |
|
|
Newbie Bulgaria Joined: Feb 20, 2009 Post Count: 1 Status: Offline |
Hi, I use DataNucleus 1.1.0m3 and can't execute SHOW/CREATE/UPDATE/ etc queries When I try to execute something different then SELECT I get an error telling me that this is not valid query. After looking at the docs several posts on this topic I tried to turn on "allowAllSQLStatements". Here is a sample code: Properties properties = new Properties(); properties.setProperty("javax.jdo.PersistenceManagerFactoryClass","org.datanucleus.jdo.JDOPersistenceManagerFactory"); properties.setProperty("javax.jdo.option.ConnectionDriverName","com.mysql.jdbc.Driver"); properties.setProperty("javax.jdo.option.ConnectionURL","jdbc:mysql://192.168.1.8/heed?autoReconnect=true&useUnicode=true&characterEncoding=utf8"); properties.setProperty("javax.jdo.option.ConnectionUserName","myuser"); properties.setProperty("javax.jdo.option.ConnectionPassword","mypass"); properties.setProperty("org.jpox.autoCreateSchema","false"); properties.setProperty("org.jpox.autoCreateColumns","false"); properties.setProperty("datanucleus.query.allowAllSQLStatements","true"); PersistenceManagerFactory loPmf = JDOHelper.getPersistenceManagerFactory(properties); PersistenceManager loPm = loPmf.getPersistenceManager(); ... Query q = loPm.newQuery("javax.jdo.query.SQL","SHOW databases;"); This ended up with the same error. I tried also with the misspelled version "allowAllSQLStaments" and also tried with the both packages I encountered on the net (datanucleus.query & org.jpox.query). The error output: You have specified an SQL statement ("SHOW databases;") that doesnt start with SELECT. This is invalid. org.datanucleus.exceptions.NucleusUserException: You have specified an SQL statement ("SHOW databases;") that doesnt start with SELECT. This is invalid. at org.datanucleus.store.rdbms.query.SQLQuery.<init>(SQLQuery.java:146) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.datanucleus.plugin.NonManagedPluginRegistry.createExecutableExtension(NonManagedPluginRegistry.j ava:576) at org.datanucleus.plugin.PluginManager.createExecutableExtension(PluginManager.java:324) at org.datanucleus.store.query.QueryManager.newQuery(QueryManager.java:125) at org.datanucleus.jdo.JDOPersistenceManager.newQuery(JDOPersistenceManager.java:1282) at com.dodconsult.bf.es.Stock.getArticleAmount(Stock.java:122) at com.dodconsult.bf.es.Stock.main(Stock.java:49) Thanks for your help! Best regards, Marian Vigenin |
||
|
|
Advanced Member USA Joined: Nov 13, 2007 Post Count: 109 Status: Offline |
The correct property name seems to be datanucleus.rdbms.sql.allowAllSQLStatements=true for non SELECT to work. PS: Andy, FYI the doc @ http://www.datanucleus.org/products/accessplatform_1_1/jdo/sql.html is misspelling the Statement keyword ---------------------------------------- Cyril |
||
|
|
|
|
|
Current timezone is GMT May 17, 2012 12:16:15 PM |