Hi List,

I think I have a typical "development" setup config question for Derby.
In "production", obviously running Derby in embedded mode has the advantage it can run in the same JVM, which is better, security/ performance wise, that over the network. BUT during development one often wishes to follow, with an external client (like DBVisualizer, Aqua Data Studio - both of which are Java Apps), what the code does to the DB.
(and possibly interact)

Therefore, what I tried is:
1/ In an application properties file I keep the default parameters for Derby. (Default = in production e.g. ConnDriver = the embedded driver) But it also keeps a "runningMode"="development" | "production" value. If its value is "development", in the application init method, some values are overwritten: cf 2/

2/ In the App init method is an if-clause thet sets/overwrites these settings in case the "runningMode" is "development":

        - ConnURL = "jdbc:derby://localhost:1527/"+ derbyHome;
        - System.getProperties().put("derby.drda.startNetworkServer","true");
        - added: try{
NetworkServerControl server = new NetworkServerControl (InetAddress.getByName("localhost"),1527);
                        server.start(null);}
                        catch (Exception e) { e.printStackTrace();
                        }
        - driver to use is set to org.apache.derby.jdbc.ClientDriver

From the Derby doc I understand firing off the Server keep it running, also beyond main(), until you manually fire a shutdown command. --> I thought this would allow me to connect via a Java DB app and never having to do any extra config apart from setting this runningMode variable in the properties file. (or with Spring, as you wish)

Yet , I get this exception:

An error occured while establishing the connection.
Type: org.apache.derby.client.am.DisconnectException Error Code: -4499
Message:
java.security.PrivilegedActionException : Error opening socket to server localhost on port 1527 with message : null

(using the ClientDriver, Login/Passw = APP/) I tried providing a password anyway ("key") and also this passw in the DB viewer app, without any effect though.

So the questions I have, are:
- I feel setting "derby.drda.startNetworkServer" to "true" AND issuing the "new NetworkServerControl(...)" are doing twice the same and that I can (as in: would better!) drop one of them. Is this correct? - Is the driver the app itself has to use to connect to the DB, after firing the Network Server: the ClientDriver, or the EmbeddedDriver? The doc got me confused about this. - Any suggestions as to how to make this work properly? :-) It looks like either the Server has shutdown already when I use the DB app (although the server was started and not shutdown that I know of), or that I need a password (thought this was never necessary, unless you explicitely set "authentication" somewhere)

Thanks for suggestions,
Philippe


Reply via email to