jRemote Client API Reference
This section helps you to access the remote jBase server using the client applications that (with a set of interfaces) this API provides. See jRemote API javadoc documentation for more information on how to use this API.
call(String subroutineName, JSubroutineParameters parameters)
Location: JConnection
Return type: JSubroutineParameters
Throws: JSubroutineNotFoundException, JRemoteException;
JSubroutineParameters represents the input/output parameters for the jBC subroutine and is an array of
JDynArray values.
//Specify subroutine parameters
JSubroutineParameters params = new JSubroutineParameters();
params.add(new JDynArray("one"));
params.add(new JDynArray("two"));
params.add(new JDynArray("three"));
//Call jBC subroutine
JSubroutineParameters returnParams = cx.call("MySubroutine", params);
//Show parameters
System.out.println("1st parameter: " + returnParams.get(0).get(1));
System.out.println("2nd parameter: " + returnParams.get(1).get(1));
System.out.println("3rd parameter: " + returnParams.get(2).get(1));
//Specify subroutine parameters
JSubroutineParameters params = new JSubroutineParameters();
params.add(new JDynArray("one"));
params.add(new JDynArray("two"));
params.add(new JDynArray("three"));
//Call jBC subroutine
JSubroutineParameters returnParams = cx.call("MySubroutine", params);
//Show parameters
System.Console.Out.WriteLine("1st parameter: " + returnParams.get(0).get(1));
System.Console.Out.WriteLine("2nd parameter: " + returnParams.get(1).get(1));
System.Console.Out.WriteLine("3rd parameter: " + returnParams.get(2).get(1));
switchAccount(String user, String account, String password)
Location: JConnection
Return type: boolean
Throws: JRemoteException;
//Switch jBASE account
boolean switchOK = cx.switchAccount("MyUserName", "MyAccount", "MyPassword");
//Switch jBASE account
bool switchOK = cx.switchAccount("MyUserName", "MyAccount", "MyPassword");
A jBASE file must be opened prior to carrying out any of these file operations. These are some of the methods defined in interface JFile to view all jBASE file operations (See javadoc documentation for more information).
The commands for the respective tasks are given below:
- Write a record to a previously opened file
write(String recordKey, JDynArray record) Return type: boolean Throws: JRemoteException;
- Write a record to a previously opened file preserving locks
writeU(String recordKey, JDynArray record, boolean blockedWrite) Return type: boolean Throws: JRecordLockedException, JRemoteException;
- Read a record from an opened file
read(String recordKey) Return type: JDynArray Throws: JRecordNotFoundException, JRemoteException
- Read a record from an opened file respecting locks or locks the specified record for update
readU(String recordKey, boolean blockedRead) Return type: JDynArray Throws: JRecordNotFoundException, JRecordLockedException, JRemoteException
Read or Write samples are given below:
//Specify record data
JDynArray record = new JDynArray();
record.replace("Field1 test data", 1);
record.replace("Field2 test data", 2);
//Write record to file
boolean writeOK = file.write("MyRecordId", record));
//Read record from file
JDynArray record2 = file.read("MyRecordId");
//Specify record data
JDynArray record = new JDynArray();
record.replace("Field1 test data", 1);
record.replace("Field2 test data", 2);
//Write record to file
bool writeOK = file.write("MyRecordId", record));
//Read record from file
JDynArray record2 = file.read("MyRecordId");
ReadU or WriteU samples are given below:
//Obtain a record lock
file.readU("MyRecordId", true); //This method call blocks if another thread already
//has acquired a lock on this record
//Write record to file respecting the record lock
file.writeU("MyRecordId", new JDynArray("Field1 test data"), true);
//Release record lock
File.releaseLock("MyRecordId");
//Obtain a record lock
file.readU("MyRecordId", true); //This method call blocks if another thread already
//has acquired a lock on this record
//Write record to file respecting the record lock
file.writeU("MyRecordId", new JDynArray("Field1 test data"), true);
//Release record lock
File.releaseLock("MyRecordId");
Non-blocking ReadU or WriteU samples are given below:
//Obtain a record lock
try {
file.readU("MyRecordId", false); //This call will throw an exception if another
//thread has acquired a lock on this record
catch(JRecordLockedException le) {
System.out.println("Record is locked.");
}
//Write record to file. This will release the record lock
file.write("MyRecordId", new JDynArray("Field1 test data"), true);
//Obtain a record lock
try {
file.readU("MyRecordId", false); //This call will throw an exception if another
//thread has acquired a lock on this record
catch(JRecordLockedException le) {
System.Console.Out.WriteLine("Record is locked.");
}
//Write record to file. This will release the record lock
file.write("MyRecordId", new JDynArray("Field1 test data"), true);
execute(String fileName)
Location: JConnection
Return type: JExecuteResults
Throws: JRemoteException;
//Execute jBASE command
JExecuteResults results = cx.execute("LIST MYFILE");
JSelectList returnList = results.getReturnList();
If(returnList.hasNext()) {
System.out.println("1st item of Select list: " + returnList.next());
}
System.out.println("CAPTURING: " + results.getCapturingVar().toString());
System.out.println("SETTING: " + results.getSettingVar().toString());
//Execute jBASE command
JExecuteResults results = cx.execute("LIST MYFILE");
JSelectList returnList = results.getReturnList();
If(returnList.hasNext()) {
System.out.println("1st item of Select list: " + returnList.next());
}
System.Console.Out.WriteLine("CAPTURING: " + results.getCapturingVar().ToString());
System.Console.Out.WriteLine("SETTING: " + results.getSettingVar().ToString());
iconv(String data, String conversion)
Location: JConnection
Return type: String
Throws: JRemoteException;
//Convert date to internal jBASE format
String result = cx.iconv("02/02/2005", "D2/");
assertEquals("13548", result);
//Convert date to internal jBASE format
String result = cx.iconv("02/02/2005", "D2/");
assertEquals("13548", result);
oconv(String data, String conversion)
Location: JConnection
Return type: String
Throws: JRemoteException;
//Convert date to internal jBASE format
String result = cx.oconv("this is a test", "MCU");
assertEquals("THIS IS A TEST", result);
//Convert date to internal jBASE format
String result = cx.oconv("this is a test", "MCU");
assertEquals("THIS IS A TEST", result);
getCommon(String name)
Location: JConnection
Return type: JDynArray
Throws: JRemoteException;
//Obtain value of a jBASE Common variable
JDynArray value = cx.getCommon("MyCommon");
System.out.println("Value of named common MyCommon: " + value.get(1));
//Obtain value of a jBASE Common variable
JDynArray value = cx.getCommon("MyCommon");
System.Console.Out.WriteLine("Value of named common MyCommon: " + value.get(1));
getMetaData()
Location: JConnection
Return type: EISMetaDataRepository
Throws: JRemoteException;
//Obtain a meta data value
EISMetaDataRepository mdRep = cx.getMetaData();
JDynArray jd = mdRep.getRepositoryEntry("MY_REPOSITORY_ENTRY");
System.out.println("Value of meta data entry: " + jd.get(1));
//Obtain a meta data value
EISMetaDataRepository mdRep = cx.getMetaData();
JDynArray jd = mdRep.getRepositoryEntry("MY_REPOSITORY_ENTRY");
System.Console.Out.WriteLine("Value of meta data entry: " + jd.get(1));
createStatement()
Location: JConnection
Return type: JStatement
Throws: JRemoteException;
execute()
Location: JStatement
Return type: JResultSet
Throws: JRemoteException;
//Execute jQL query
JStatement statement = cx.createStatement();
JResultSet rs = statement.execute("LIST MYFILE *A1");
while(rs.next()) {
JDynArray jd = rs.getRow();
System.out.println(jd.get(1));
}
//Execute jQL query
JStatement statement = cx.createStatement();
JResultSet rs = statement.execute("LIST MYFILE *A1");
while(rs.next()) {
JDynArray jd = rs.getRow();
System.Console.Out.WriteLine(jd.get(1));
}
begin() commit() rollback() Location: JConnection Return types: void Throws: JRemoteException;
//Start a transaction and perform a rollback
cx.begin();
myfile.write("MyRecordId", new JDynArray("My test data"));
cx.rollback();
//Start a transaction and perform a commit
cx.begin();
myfile.write("MyRecordId", new JDynArray("My test data"));
cx.commit();
//Start a transaction and perform a rollback
cx.begin();
myfile.write("MyRecordId", new JDynArray("My test data"));
cx.rollback();
//Start a transaction and perform a commit
cx.begin();
myfile.write("MyRecordId", new JDynArray("My test data"));
cx.commit();
setTerminalOutputWriter(Writer writer)
Location: JConnection
Return type: void
Throws: Nothing
//Set the writer for the terminal output to capture standard output
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Writer writer = null;
try {
writer = new OutputStreamWriter(bos, "UTF-8");
catch (UnsupportedEncodingException e) {
System.out.println("Error while creating OutputStreamWriter.");
}
cx.setTerminalOutputWriter(writer);
//Set the writer for the terminal output to capture standard output
System.IO.MemoryStream bos = new System.IO.MemoryStream();
System.IO.StreamWriter writer = null;
try
{
writer = new System.IO.StreamWriter(bos, System.Text.Encoding.GetEncoding("UTF-8"));
}
catch (System.IO.IOException)
{
System.Console.Out.WriteLine("Error while creating OutputStreamWriter.");
}
cx.TerminalOutputWriter = writer;
In this topic