Using Cache' Post RDBMS From Mathematica By Telnet

Junzo SATO

Copyright (c) 2001, Junzo SATO. All rights reserved.

June 6th 2001

Cache' Post RDBMS from InterSystems is an OODB. It possesses data and functions in classes. Cache' Terminal is a handy telnet client application to control database by Cache' ObjectScript. By adding Mathematica the functionality of telnet communication, it becomes possible for Mathematica to take a role of Cache' Terminal.

Configurations

The author developed a Java class MathSocketTerminal to enable Mathematica to be able to send and receive data via TCP/IP socket. This class is loaded by Mathematica. Cache' database runs on a remote computer. The Java application package RelayStationArgs were built too. It runs on the remote computer so that it can relay packets between MathSocketTerminal's socket and Cache' telnet port.

Load J/Link

J/Link is loaded and installed.

[Graphics:Images/CacheTelnet_gr_1.gif]
[Graphics:Images/CacheTelnet_gr_2.gif]
[Graphics:Images/CacheTelnet_gr_3.gif]

Load MathSocketTerminal

The communication tool MathSocketTerminal is loaded. An object of this class is constructed.

[Graphics:Images/CacheTelnet_gr_4.gif]
[Graphics:Images/CacheTelnet_gr_5.gif]

Create SocketListener

SocketListener is a class which can receive TCP/IP packets. Incoming data is read and transferred to Mathematica by evaluating pre-installed handler.

[Graphics:Images/CacheTelnet_gr_6.gif]
[Graphics:Images/CacheTelnet_gr_7.gif]

The handler simply prints received string in this example.

[Graphics:Images/CacheTelnet_gr_8.gif]
[Graphics:Images/CacheTelnet_gr_9.gif]
[Graphics:Images/CacheTelnet_gr_10.gif]
[Graphics:Images/CacheTelnet_gr_11.gif]
[Graphics:Images/CacheTelnet_gr_12.gif]

Start Session

[Graphics:Images/CacheTelnet_gr_13.gif]
[Graphics:Images/CacheTelnet_gr_14.gif]

To RelayStation with Cache' PRDBMS

Login

RelayStation's server port on a remote computer is opened.
Because GUI for RelayStation was omitted for efficiency, RelayStation in RelayStationArgs is launched by command: java RelayStation.RelayStation

Connection to the RelayStation is established.

[Graphics:Images/CacheTelnet_gr_15.gif]
[Graphics:Images/CacheTelnet_gr_16.gif]

Cache' telnet server requests login password at the very first of the session.

[Graphics:Images/CacheTelnet_gr_17.gif]
[Graphics:Images/CacheTelnet_gr_18.gif]
[Graphics:Images/CacheTelnet_gr_19.gif]
[Graphics:Images/CacheTelnet_gr_20.gif]

Unicode And Command : s, w

A word "Tokyo Prefecture" in Japanese is set.

[Graphics:Images/CacheTelnet_gr_21.gif]
[Graphics:Images/CacheTelnet_gr_22.gif]
[Graphics:Images/CacheTelnet_gr_23.gif]
[Graphics:Images/CacheTelnet_gr_24.gif]

Inside Cache' unicode version, the word is stored as three unicode characters.

[Graphics:Images/CacheTelnet_gr_25.gif]
[Graphics:Images/CacheTelnet_gr_26.gif]
[Graphics:Images/CacheTelnet_gr_27.gif]
[Graphics:Images/CacheTelnet_gr_28.gif]
[Graphics:Images/CacheTelnet_gr_29.gif]
[Graphics:Images/CacheTelnet_gr_30.gif]
[Graphics:Images/CacheTelnet_gr_31.gif]
[Graphics:Images/CacheTelnet_gr_32.gif]
[Graphics:Images/CacheTelnet_gr_33.gif]
[Graphics:Images/CacheTelnet_gr_34.gif]

ZIP Database And Query

The namespace is changed from USER to ZIP by command:
zn "ZIP"

[Graphics:Images/CacheTelnet_gr_35.gif]
[Graphics:Images/CacheTelnet_gr_36.gif]
[Graphics:Images/CacheTelnet_gr_37.gif]

The command:
do ##class(%Library.ResultSet).RunQuery("Zip.ZipTable","getTown","1940032")
runs query method getTown(zip7) in the class Zip.ZipTable with a string argument zip7 = "1940032"
It returnes prefecture, city, and town in database.

[Graphics:Images/CacheTelnet_gr_38.gif]
[Graphics:Images/CacheTelnet_gr_39.gif]
[Graphics:Images/CacheTelnet_gr_40.gif]
[Graphics:Images/CacheTelnet_gr_41.gif]
[Graphics:Images/CacheTelnet_gr_42.gif]
[Graphics:Images/CacheTelnet_gr_43.gif]

The command:
do ##class(%Library.ResultSet).RunQuery("Zip.ZipTable","getZipCode","“Œ‹ž“s","’¬“cŽs")
runs query getZipCode(kanjiPref, kanjiCity) in the class Zip.ZipTable with string arguments: kanjiPref  = "“Œ‹ž“s", kanjiCity = "’¬“cŽs". It returns town names.

[Graphics:Images/CacheTelnet_gr_44.gif]
[Graphics:Images/CacheTelnet_gr_45.gif]
[Graphics:Images/CacheTelnet_gr_46.gif]
[Graphics:Images/CacheTelnet_gr_47.gif]

Closing Connection

[Graphics:Images/CacheTelnet_gr_48.gif]

Quit

[Graphics:Images/CacheTelnet_gr_49.gif]
[Graphics:Images/CacheTelnet_gr_50.gif]
[Graphics:Images/CacheTelnet_gr_51.gif]
[Graphics:Images/CacheTelnet_gr_52.gif]


Converted by Mathematica      June 6, 2001