cancel
Showing results for 
Search instead for 
Did you mean: 

Java interface question

vcd
New Contributor

Hi,

We were trying to use the java interface with kdb+ as shown under:
https://code.kx.com/trac/browser/kx/kdb%2B/interfaces/java

Specifically we are trying to use ".u.sub" to subscribe to a
particular table for certain values of a column (as and when the
updates come in). In an infinite loop we then use the listen()
function to wait for the matching messages to come in and after call
our logic to process those. For some reason though it fails on the
"Flip t = toFlip(r);" part ... and the type of r is not 98 but 0. Flip
is needed to retrieve the rows and cols within that received message I
believe.

Is listen not the function to use or are we doing something else
wrong?

----------------------
Connection server = new ConnectionImpl("localhost", 5010);
String[] rootords={"abc","def","ghi"};
server.query(".u.sub", "table_name", rootords);
while (true){
Object r = server.listen();
System.out.println("Type of result is: " + typeOf(r);
Flip t = toFlip(r);
------------------------

Regards,
vcd.

2 REPLIES 2

vcd
New Contributor
Hi,We looked some more into this and this seems to be making it work:Flip t = toFlip(at(r,2))instead ofFlip t = toFlip(r);After this the rows and cols, etc. can all be retrieved.There is another issue though. It seems we cant subscribe to multipletables. The logic we are using is:----------------------String[] tables={"table_name1", "table_name2"};server.query(".u.sub", tables);----------------------It gives a type error. Subscribing to multiple tables from a q sessiondirectly works fine but not from within the java app. Any suggestionsas to what could be the issue?Regards,vcd.On Sep 23, 3:13�pm, vcd wrote:> Hi,>> We were trying to use the java interface with kdb+ as shown under:https://code.kx.com/trac/browser/kx/kdb%2B/interfaces/java>> Specifically we are trying to use ".u.sub" to subscribe to a> particular table for certain values of a column (as and when the> updates come in). In an infinite loop we then use the listen()> function to wait for the matching messages to come in and after call> our logic to process those. For some reason though it fails on the> "Flip t = toFlip(r);" part ... and the type of r is not 98 but 0. Flip> is needed to retrieve the rows and cols within that received message I> believe.>> Is listen not the function to use or are we doing something else> wrong?>> ----------------------> Connection server = new ConnectionImpl("localhost", 5010);> String[] rootords={"abc","def","ghi"};> server.query(".u.sub", "table_name", rootords);> while (true){> � � �Object r = server.listen();> � � �System.out.println("Type of result is: " + typeOf(r);> � � �Flip t = toFlip(r);> ------------------------>> Regards,> vcd.

Aaron_Davies
New Contributor

X-Mailer: Apple Mail (2.936)