Welcome Guest  |  Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1424 times and has 1 reply Next Thread
Male marianv
Newbie



Bulgaria
Joined: Feb 20, 2009
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
Problems with "allowAllSQLStatements"

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
[Feb 20, 2009 7:19:48 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male cyril
Advanced Member
Member's Avatar

USA
Joined: Nov 13, 2007
Post Count: 109
Status: Offline
Reply to this Post  Reply with Quote 
Re: Problems with "allowAllSQLStatements"

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
[Aug 20, 2009 5:07:40 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread