Hi Sandya,
since I'm back in my office again, I thought it would be a nice idea to present you a MWE (minimal working example):
import de.independit.scheduler.shell.SDMSServerConnection;
import de.independit.scheduler.server.output.SDMSOutput;
import de.independit.scheduler.server.output.SDMSLineRenderer;
import java.io.IOException;
public class SimpleAccess
{
private static SDMSServerConnection sc = null;
private static SDMSLineRenderer lr = null;
public static void main(String argv[])
{
sc = new SDMSServerConnection(
"localhost", /* host */
2506, /* port */
"SYSTEM", /* user */
"G0H0ME", /* password */
0, /* connection timeout disabled */
false /* no TLS */
);
lr = new SDMSLineRenderer();
try {
/* connect first. Since we don't want to do something special (e.g. use TLS)
we can supply a null instead of an de.independit.scheduler.SDMSApp.Options object
*/
SDMSOutput o = sc.connect(null /* no special options */);
if (o.error != null) {
System.err.println("Connect Error: " + o.error.code + ", " + o.error.message);
System.exit(1);
}
/* Now we execute some statement.
If you need to execute multiple statements, you'll have to call execute() multiple times.
But note that a "Multicommand" is regarded a single statement, even if it's several megabytes long.
*/
o = sc.execute("LIST SESSIONS;");
try {
/* here we print the result on stdout. Just for the example */
lr.render(System.out, o);
} catch (Exception e) { /* a so-called FatalException, which is a subclass of Exception, can occur here */
System.err.println("Something went wrong: " + e.toString());
}
/* here we close the connection again */
sc.finish();
} catch (IOException ioe) {
System.err.println("Something went wrong : " + ioe.toString());
System.exit(1);
}
System.exit(0);
}
}
That's all.
In order to compile (and execute) it, I did:
[ronald@ocelot tmp]$ CLASSPATH=$CLASSPATH:$BICSUITEHOME/lib/BICsuite.jar
[ronald@ocelot tmp]$ export CLASSPATH
[ronald@ocelot tmp]$ javac SimpleAccess.java
[ronald@ocelot tmp]$ java SimpleAccess
List of Sessions
THIS SESSIONID PORT START TYPE USER UID IP TXID IDLE STATE TIMEOUT INFORMATION STATEMENT WAIT
---- --------- ---- ----------------------------- --------- -------------------------------- ---- --------- -------- ---- ------ ------- ----------------------------------------- -------------- ----
1001 2506 Wed Oct 07 13:10:12 CEST 2020 JOBSERVER GLOBAL.EXAMPLES.HOST_1.SERVER 1047 127.0.0.1 45363868 1 IDLE 300 jobserver[sche...@ocelot.independit.de]
1003 2506 Wed Oct 07 13:10:12 CEST 2020 JOBSERVER GLOBAL.EXAMPLES.HOST_2.SERVER 1057 127.0.0.1 45363874 1 IDLE 300 jobserver[sche...@ocelot.independit.de]
1007 2506 Wed Oct 07 13:26:10 CEST 2020 JOBSERVER GLOBAL.EXAMPLES.LOCALHOST.SERVER 1037 127.0.0.1 45363871 1 IDLE 300 jobserver[sche...@ocelot.independit.de]
* 1013 2506 Wed Oct 07 15:22:57 CEST 2020 USER SYSTEM 0 127.0.0.1 45363876 0 ACTIVE 0 <null> LIST SESSIONS;
1234321 0 Wed Oct 07 13:10:11 CEST 2020 USER SchedulingThread 2 <null> 45363856 7 IDLE 0 <null>
1234322 0 Wed Oct 07 13:10:11 CEST 2020 USER GarbageThread 2 <null> 45362320 737 IDLE 0 <null>
1234323 0 Wed Oct 07 13:10:11 CEST 2020 USER TriggerThread 2 <null> 45363841 11 IDLE 0 <null>
1234324 0 Wed Oct 07 13:10:11 CEST 2020 USER PoolThread 2 <null> 45363577 138 IDLE 0 <null>
19630127 0 Wed Oct 07 13:10:11 CEST 2020 USER TimerThread 2 <null> 45363844 11 IDLE 0 <null>
9 Session(s) found
As you can see, no higher magic involved.
I hope you like it.
Best regards,
Ronald