Has anyone any experience in using the rawSQL plugin to create and alter tables from a runtime application?
Servoy R2 2.2.5 build-337 on Mac OS 10.4.6 using Java 1.5.0_06
I have a method
var ans = plugins.dialogs.showQuestionDialog( "RawSQL Test", "Create field?", "OK", "cancel")
if (ans == "cancel") {return}
application.output("ALTER TABLE main ADD testint INTEGER NULL")
var done = plugins.rawSQL.executeSQL("user_data","main","ALTER TABLE main ADD testint INTEGER NULL")
if (done)
{
application.output("SUCCESS")
plugins.rawSQL.flushAllClientsCache("user_data","main")
application.output("FLUSHED")
}
else
{
application.output('SQL error: '+plugins.rawSQL.getExceptionMsg())
plugins.dialogs.showErrorDialog('Error', 'SQL error: '+plugins.rawSQL.getExceptionMsg(), 'Ok')
}
It works fine in developer. Console says
===== Saturday, 10 June 2006 11:06:03 PM Australia/Melbourne =====
ALTER TABLE main ADD testint INTEGER NULL
SUCCESS
FLUSH
I can see the new column testint in Sybase Central. Restarting Developer I can access the testint.
When I build a runtime and execute the same method, I get the following Java error.
ALTER TABLE main ADD testint INTEGER NULL
java.rmi.ConnectException: Connection refused to host: eMac.local; nested exception is:
java.net.ConnectException: Connection refused
java.rmi.ConnectException: Connection refused to host: eMac.local; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:306)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:84)
at com.servoy.j2db.plugins.ClientPluginAccessProvider.getServerService(Unknown Source)
at com.servoy.r2.plugins.rawSQL.RawSQLProvider.createSQLService(RawSQLProvider.java:30)
at com.servoy.r2.plugins.rawSQL.RawSQLProvider.js_executeSQL(RawSQLProvider.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:347)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1254)
at org.mozilla.javascript.gen.c17.call(test2:6)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1254)
at org.mozilla.javascript.gen.c11.call(STARTUP:15)
at com.servoy.j2db.scripting.f.executeFunction(Unknown Source)
at com.servoy.j2db.FormManager.do(Unknown Source)
at com.servoy.j2db.FormManager$3.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:430)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.(Socket.java:365)
at java.net.Socket.(Socket.java:178)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
… 27 more
java.lang.NullPointerException
java.lang.NullPointerException
at com.servoy.r2.plugins.rawSQL.RawSQLProvider.js_executeSQL(RawSQLProvider.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:347)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1254)
at org.mozilla.javascript.gen.c17.call(test2:6)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1254)
at org.mozilla.javascript.gen.c11.call(STARTUP:15)
at com.servoy.j2db.scripting.f.executeFunction(Unknown Source)
at com.servoy.j2db.FormManager.do(Unknown Source)
at com.servoy.j2db.FormManager$3.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
SQL error: java.lang.NullPointerException null
Error occured informing client plugin udp, error: java.lang.NullPointerException
In Activity Monitor (this is on a Mac) I note that for Developer there’s the dbsrv9 process, while for RT it’s the dbeng9 process that loads when the RT app is started. Is this relevant?
Any tips welcome!