Brandon Dohman wrote:
I’m going to be deploying a java desktop app, and I am curious on how to
start the database server from within the code. I have done all of my
testing through netbeans, and have been able to get all of the
connections and transactions to go smoothly, but the database was
started by using the tools > javadb > start db server option in netbeans.
With deployment, I’ll need to be able to start the code from within my
java code.
There are several ways to start the network server from Java code. The
Derby Server and Administration guide [1] describes at least two ways in
the topic called "Starting the Network Server from a Java application":
http://db.apache.org/derby/docs/10.3/adminguide/tadminconfig814963.html
(for Derby 10.3)
Using the org.apache.derby.drda.NetworkServerControl API [2] probably
gives you the most flexibility.
If you want to start the server as a separate process instead of
embedded in the same JVM as your application, you can use Runtime.exec()
calls from your Java code.
--
John
[1]: http://db.apache.org/derby/docs/10.3/adminguide/
[2]:
http://db.apache.org/derby/docs/10.3/publishedapi/jdbc4/org/apache/derby/drda/NetworkServerControl.html