Kathey Marsden wrote:
> Frank Griffin wrote:
>> get-go (of course, how you could open JDBC access without actually
>> opening JDBC access is a bit of a conundrum).
>>
>> Any ideas or direction ?
>>
>>
> You could connect with the embedded driver to do your initial setup
> before starting network server and letting clients in.
I gave this a try, and almost got it to work. My code does its initial
setup by loading the embedded driver and submitting CREATE FUNCTION
statements, and that works fine. When it's done, it tries to turn
control over to the Network Server. The problem is, the Network Server
returns immediately, the app returns, and the JVM shuts down.
In the code below, the NOMADDerbyUpdateQueries class does the initial
setup, and should then execute periodically to see if any new queries
(Table Functions) have been dropped into its directory (hence the
timer.schedule() and timer.cancel()).
Is there a way to get the Network Server to block until it is told to
shut down ? If not, is there a way to query the status of the Network
Server, so that I can wait in a timed loop until I detect that it's been
stopped ?
derby.log at the end of this has:
----------------------------------------------------------------
2008-01-25 16:52:13.569 GMT:
Booting Derby version The Apache Software Foundation - Apache Derby -
10.4.0.0 alpha - (614553): instance c013800d-0117-b1dd-1b95-00000f6f8d10
on database directory /data/ftg/tmp/derbyhome/data/NOMAD
Database Class Loader started - derby.database.classpath=''
Apache Derby Network Server - 10.4.0.0 alpha - (614553) started and
ready to accept connections on port 1527 at 2008-01-25 16:52:14.730 GMT
----------------------------------------------------------------
The code is:
public static
void
main( String[] args )
throws Exception
{
NOMADDerbyUpdateQueries oUpdate;
NetworkServerControl oServer;
Timer timer;
oUpdate = new NOMADDerbyUpdateQueries();
oUpdate.run();
timer = new Timer( true );
timer.schedule( oUpdate,
0L,
10000L );
if ( args.length > 0 )
{
InetAddress ia = InetAddress.getByName( "localhost" );
oServer = new NetworkServerControl
( ia,
Integer.parseInt( args[0] ) );
}
else
{
oServer = new NetworkServerControl();
}
oServer.start( new PrintWriter( System.out ) );
timer.cancel();
return;
}
Thanks again,
Frank