<REMOTE EXECUTE INVALID WRITE>: Iris with jdbc driver
Hi....
I am trying to execute legacy routines from Cache 2018, into new environment with Iris 2021. I use new JDBC driver to make this connection, and change my java code to execute this legacy routines. But I get this write error: <REMOTE EXECUTE INVALID WRITE>
I changed the mnemonic routine to populate object and return this object to java. And the java class convert this object to json.
This is my simple classes used for this process, just to exemplification:
Java Class
package test; import java.sql.SQLException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.intersystems.jdbc.IRIS; import com.intersystems.jdbc.IRISConnection; import com.intersystems.jdbc.IRISDataSource; import com.intersystems.jdbc.IRISObject; public class Reader { public static final String CACHE_CLASS_NAME = "Utils.CSW1JavaFunctions"; public IRISConnection connection; public IRIS iris; public Reader(IRISConnection connection) throws SQLException { this.connection = connection; this.iris = IRIS.createIRIS(connection); } public static void main(String[] args) throws SQLException { IRISDataSource dataSource = new IRISDataSource(); dataSource.setServerName("localhost"); dataSource.setPortNumber(1972); dataSource.setDatabaseName("TEST"); dataSource.setUser("_SYSTEM"); dataSource.setPassword("xxxxxxxxx"); IRISConnection connection = (IRISConnection) dataSource.getConnection(); Reader reader = new Reader(connection); try { JsonNode jsonNode = reader.connect("IrisWrite", "param1", "param1"); System.out.println(jsonNode.toString()); } catch (Exception exc) { exc.printStackTrace(); } } public JsonNode connect(String method, Object... _args) throws Exception { ObjectMapper mapper = new ObjectMapper(); JsonNode jsonNode = null; try { IRISObject data = (IRISObject) iris.classMethodObject(CACHE_CLASS_NAME, method, _args); String string = (String) data.invoke("%ToJSON"); data.close(); jsonNode = (JsonNode) mapper.readTree(string); return jsonNode; } catch (Exception ex) { ex.printStackTrace(); } return null; } }
Iris class:
ClassMethod IrisWrite(args...) As %RegisteredObject { set %return = ##class(%ZEN.proxyObject).%New() set %return.lines = ##class(%ListOfDataTypes).%New() try { ; use $io::"^%SMMNEMONIC" ; write args(1) write args(2) ; set regObj = ##class(%ZEN.Auxiliary.altJSONProvider).%ObjectToAET(%return,,,"d") ; return regObj } catch ex { throw ex } } //Mnemonic routine: %SMMNEMONIC ; ; wstr(string) ; set string=$zstrip($zstrip(string,"<>W"),"*C") quit:string="" do %return.lines.Insert(string) quit
This error is new to me.
How to populate a object with write command?
Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 EDT
Do not use %ZEN, it’s deprecated. There is Native JSON support, and %JSON.Adaptor, use this instead. Any output with write command will produce this error.
Hi @Maslennikov.Dmitry...
I get the error on execute the line with "write args(1)" after "use $io..."
Not possible execute "write" from process with JDBC connection.
I will change all %Zen from my code coming soon. Thanks for warning
You can't call native api methods which write to device as is.
If you need to call some piece of code which writes to device use this wrapper:
So in your case it would be something like:
IRISObject data = (IRISObject) iris.classMethodObject(CACHE_CLASS_NAME, method, _args); String string = iris.classMethodString("SomeClass", "OutputToStr", data, "ToJSON") data.close();