How can I run the apache derby program jar file?

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

However, when closing eclipse (and the server is not connected to 1527) while executing the jar, I get this error

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

This is clear. But I want to distribute the JAR. So, is there a way to start the server programmatically when the JAR is running?


source to share

3 answers

You can start NetworkServer programmatically :

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





The simplest is to use embedded Derby

        conn = DriverManager.getConnection("jdbc:derby:" + DATA_STORE + ";create=true");




You need to start the server programmatically.

How this is done is described in the manual:



All Articles