As the result of the post by Bryan Buchanan I have started have a look at the Java API to interact with D3.
I'm working on AlmaLinux 8.9 with D3 10.4 installed.
I have downloaded the file MVSPJavaAPI.zip and successfully compiled and used then MVSPJavaAPI/mvspTest/mvspTest.java program. The program connected instantly and all data accesses were instant.
Using that as my basis I created a console program but ran into an issue with connecting. The connection in my program is taking 2 to 3 seconds to complete. Data access is instant after the connection occurs. At the same time I am seeing the following message lines in /var/log/messages:
Mar 10 20:49:13 Alma8 systemd[1]: Started D3's per connection MVSP server for pick0 (127.0.0.1:53850).
Mar 10 20:49:16 Alma8 systemd[1]: D3MVSPpick0@2-127.0.0.1:9000-127.0.0.1:53850.service: Main process exited, code=exited, status=1/FAILURE
Mar 10 20:49:16 Alma8 systemd[1]: D3MVSPpick0@2-127.0.0.1:9000-127.0.0.1:53850.service: Failed with result 'exit-code'.
I do not see these message lines when using the mvspTest.java program.
I cannot see any significant difference between the code in mvspTest.java and my code that can explain the delay in connecting.
My code is this:
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());
}
}
}
Any help would be appreciated.
PS: I have tried to post this in the more generic forum but I can't see if that succeeded. My apologies if this turns out to be a repeat post.
------------------------------
James Carthew
Application Specialist
LRS Health Pty Ltd
Heidelberg VIC AU
------------------------------