Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I start apache derby programmatically jar file?

Tags:

java

jar

derby

I have a Java application, which uses Apache Derby. Using Eclipse Export option, I exported it as JAR file. When I am running Eclipse, and the server is connected to port 1527, the JAR executes correctly.

However when eclipse is closed, (and the server is not connected to 1527) on executing jar, i get this error

java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.

This is understandable. But i want to distribute the JAR. So is there a way to start the server programmatically, whenever JAR is executed?

like image 590
Vinayak Garg Avatar asked Apr 26 '26 10:04

Vinayak Garg


1 Answers

You can start the NetworkServer programmatically:

NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("myhost"),1621)

serverControl.shutdown();
like image 112
oers Avatar answered Apr 28 '26 22:04

oers