Skip to main content

As the result of a post by Bryan Buchanan I have started looking at using the Java API to access Rocket D3 10.4 on AlmaLinux 8.9.

I have downloaded the file MVSPJavaAPI.zip and successfully compiled and run MVSPJavaAPI/samples/mvspTest.java. When I used this program the connection was instant and all other accesses were also instant. 

I then attempted to create my own simple Java program based on what I could see in mvspTest.java. When I ran it I found that there was a 2 to 3 second delay when making the connection. The data retrieval part of the program worked and was instant. At the same time the following error message lines appear in /var/log/messages:

Mar 10 19:55:06 Alma8 systemd[1]: D3MVSPpick0@0-127.0.0.1:9000-127.0.0.1:54186.service: Main process exited, code=exited, status=1/FAILURE
Mar 10 19:55:06 Alma8 systemd[1]: D3MVSPpick0@0-127.0.0.1:9000-127.0.0.1:54186.service: Failed with result 'exit-code'.

These message lines did not occur when I used mvspTest.java.


Can anyone give a clue why I am seeing the difference in behaviour? My code is as follows:

MvspConsole.java

import com.rocketsoftware.mvapi.*;
//import com.rocketsoftware.mvapi.ResultSet.*;
//import com.rocketsoftware.mvapi.exceptions.*;
import java.util.Properties;

class MvspConsole {
  static MVConnection mvspHandle;

  public static void main(String[] args) {
    System.out.println("Started...");

    Properties props = new Properties();
    props.setProperty("username", "jrcar");
    props.setProperty("password", "0xygen16");

    String url = "jdbc:mv:D3:localhost:9000";
    mvspConnect(url, props);

    mvspLogto("mvdemo", "");

    mvspRead("customers", "12");

    mvspClose();
  }

  static void mvspConnect(String url, Properties props){
    System.out.println("Connecting...");
    try {
        mvspHandle = new MVConnection(url, props);
    }
    catch (Exception ex){
      System.out.println("new MVConnection: Unexpected exception: " + ex.toString());
      System.out.println(" : " + ex.getMessage());
      System.out.println("Cause: " + ex.getCause());
      return;


    }
    System.out.println("Connected");
  }

  static void mvspClose(){
    try {
      mvspHandle.close();
    } catch (Exception ex) {
      System.out.println("Couldn't close mvcHandle");
    }
  }

  static void mvspLogto(String account, String pwd){
    try {
      mvspHandle.logTo(account, pwd);
      System.out.println("Logto: " + account);
    } catch (Exception ex) {
      System.out.println("Exception: " + ex.toString());
      System.out.println(" : " + ex.getMessage());
    }
  }

  static void mvspRead(String fileName, String id){
    try {
      String item = mvspHandle.fileRead(fileName, id);
      item = mvspHandle.swap(item, MVConstants.AM, "|");
      System.out.println("Read item ...");
      System.out.println(item);
    } catch (Exception ex) {
      System.out.println("Exception: " + ex.toString());
      System.out.println(" : " + ex.getMessage());
    }
  }
}



------------------------------
James Carthew
Application Specialist
LRS Health Pty Ltd
Heidelberg VIC AU
------------------------------

Be the first to reply!