Nueva publicación

Encontrar

Pregunta
· 14 ene, 2025

IRIS (External language) JavaGateway - how to pass byte[] to Java Method

As part of a migration project from a bunch of java classes to IRIS, we need to maintain a few jar files due to some external dependencies.

The problem I am seeing is that I cannot pass a byte array ( byte[] ) from ObjectScript to the Java Class. I have tried a number of different ways

I have reproduced in a java class and Objectscript class:
Java Class:

package wrc;

public class TestJava {
    
    public static void testByteArr(byte[] keyBytes) {

        System.out.println("keyBytes getClass() = " + keyBytes.getClass() );
        System.out.println("keyBytes toString() = " + keyBytes.toString() );
    }

    public static void testByte(byte obj) {

        System.out.println("byte getClass() = " + ((Object)obj).getClass().getName() );
        System.out.println("byte toString() = " + ((Object)obj).toString() );
    }

    public static void testStr(String obj) {

        System.out.println("obj getClass() = " + ((Object)obj).getClass().getName() );
        System.out.println("obj toString() = " + obj );
    }

    public static void testObj(Object obj) {

        System.out.println("obj getClass() = " + ((Object)obj).getClass().getName() );
        System.out.println("obj toString() = " + obj.toString() );
    }

}

ObjectScript Class

Class POH.wrc Extends %RegisteredObject
{

ClassMethod testMe()
{

    #DIM javaGate As %External.JavaGateway = $SYSTEM.external.getJavaGateway()
    do javaGate.addToPath("C:\temp\wrc.jar")

    set test = javaGate.new("wrc.TestJava")

    do test.testStr("test string") // works
    do test.testByte($C(40)) // works
    try { 
        w !,"TRY #"_$I(TEST)
        do test.testByteArr($C(40) _ $C(41))
    } catch (e)
    {
        w " *** FAILED: " _ e.DisplayString()
    }

    try { 
        w !,"TRY #"_$I(TEST)
        set bArr = ##class(%ListOfDataTypes).%New()
        do bArr.Insert($C(40))
        do bArr.Insert($C(41))
        do test.testByteArr(bArr)
    } catch (e)
    {
        w " *** FAILED: " _ e.DisplayString()
    }

    try { 
        w !,"TRY #"_$I(TEST)
        #Dim arg As %Stream.GlobalBinary = ##Class(%Stream.GlobalBinary).%New()
        do arg.Write($C(40))
        do arg.Write($C(41))
        do test.testByteArr(arg)
    } catch (e)
    {
        w " *** FAILED: " _ e.DisplayString()
    }

    try { 
        w !,"TRY #"_$I(TEST)
        #Dim argc As %Stream.GlobalCharacter = ##Class(%Stream.GlobalCharacter).%New()
        do argc.Write($C(40))
        do argc.Write($C(41))
        do test.testByteArr(argc)
    } catch (e)
    {
        w " *** FAILED: " _ e.DisplayString()
    }
}

}

Each fail with:
TRY #x *** FAILED: <GATEWAY> java.lang.IllegalArgumentException sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) argument type mismatch

The String and Byte tests above work fine...

2 comentarios
Comentarios (2)2
Inicie sesión o regístrese para continuar
Pregunta
· 14 ene, 2025

INSERT OR UPDATE WITH A COUNTER

Hello,

So i want to use the INSERT OR UPDATE command so i can update a COUNTER for a given name:

 

INSERT OR UPDATE myTable
SET name='Omer',  counter = counter + 1;

 


as you can see with the above code - if the row is non-existent then we get an error because COUNTER is NULL! 
I tried the following to fix this but all have failed:

 


INSERT OR UPDATE myTable
SET name = 'Omer', 
    counter = CASE 
        WHEN counter IS NULL THEN 1 
        ELSE counter + 1
    END

 


INSERT OR UPDATE myTable SET name='Omer',counter = COALESCE(counter + 1, 1)

 

 

INSERT OR UPDATE myTable SET name='Omer',counter = IFNULL(counter + 1, 1)

For any of the solutions above i received the error:
 

  [SQLCODE: <-400>:<Fatal error occurred>]

  [%msg: <Unexpected error occurred: <UNDEFINED>%0Ao+3^%sqlcq.74.1 *sqldatad(3)>]

 

Side Note: Running the query below does work:

 

INSERT OR UPDATE myTable SET name='Omer',counter= 1

So this implies that problem is indeed with using the counter when it is NULL...

 

 

Would love to get some insight on that, Thx!

26 comentarios
Comentarios (26)6
Inicie sesión o regístrese para continuar
Artículo
· 13 ene, 2025 Lectura de 2 min

第七十二章 管理设备和助记词空间 - 定义设备

第七十二章 管理设备和助记词空间 - 定义设备

定义设备

可以在 Management PortalDevices (设备) 配置设置中定义、编辑和删除设备。您输入的信息存储在 ^%IS 全局变量中。有关此全局的更多信息,请参阅 ^%IS 全局的结构。

如果在 IRIS 运行时进行设备更改,系统会提示是否要在不重新启动 IRIS 的情况下激活更改。如果同意激活更改,则新定义将立即提供给用户。

访问设备

Windows 系统上,必须将设备编号用于作业间通信设备和常规联锁设备。对于终端和打印机,可以使用您分配的设备助记词或设备编号。

UNIX 系统上,可以使用 UNIX 文件规范来引用文件,也可以设置设备编号来引用文件。

Comentarios (0)1
Inicie sesión o regístrese para continuar
Artículo
· 13 ene, 2025 Lectura de 1 min

ALARMエラーが発生する理由

これは InterSystems FAQ サイトの記事です。

<ALARM>エラーは、クライアントアプリでタイムアウトが発生し、その結果InterSytemsサーバのプロセスがあわせて終了している状況をあらわしています。

クライアントアプリで、タイムアウト設定を無効にすることで回避できる可能性があります。

例えば、クライアントアプリから初回実行するSQL文がある場合、初回実行時のみInterSystems製品内部にクエリキャッシュ(=コンパイル済クエリ)を生成するため(※1)通常実行よりも時間がかかります(2回目以降の実行ではコンパイルは行われません)。

例えば、コンパイルに非常に時間がかかるSQL文の初回実行をクライアントアプリから命令し、タイムアウト以内に応答が戻らない場合 <ALARM> エラーが発生します。

※1:IRIS2020.1以降では埋め込みSQLで記述されたクエリも、初回実行時にコンパイルされます(2019.1以前では、埋め込みSQLを含むクラス/ルーチンがコンパイルされるタイミングでSQLもコンパイルされます)。

Comentarios (0)1
Inicie sesión o regístrese para continuar
Pregunta
· 13 ene, 2025

Python Iris.CreateIRIS generates connection error

Hi, I'm trying to use the iris python package to create a connection to and Iris Health instance (Docker Container), but getting and error. I can login to the instance using the UI with the same uname/password but unable to create the python connection. Any suggestions?

conn = iris.connect("testserver",52222,"%SYS","username","password")

After executing this I get an exception trap
An error occurred: Invalid Message Count: expected: 1 got: 825110831

1 Comentario
Comentarios (1)1
Inicie sesión o regístrese para continuar