Pessoal, pesquisei na documentação do próprio Java DB e descobri que uma vez que o driver for carregado, o banco será iniciado automaticamente.
Segue um trecho do documento:
"Starting Derby as an embedded database
To start Derby, you start the Derby JDBC driver. Starting the Derby driver starts up the
complete Derby system within the current JVM.
For example, when using the JBDC driver manager directly within Java code, you
typically start a JDBC driver in one of these ways:
? Specify the jdbc.drivers system property, which allows users to customize the JDBC
drivers used by their applications. For example:
java -Djdbc.drivers=org.apache.derby.jdbc.EmbeddedDriver
applicationClass
? Load the class directly from Java code using the static method Class.forName. For
example:
Class.forName(“org.apache.derby.jdbc.EmbeddedDriver”);
? If your application runs on JDK 1.6 or higher, then you do not need to explicitlty load
the EmbeddedDriver. In that environment, the driver loads automatically and the
engine starts when your application requests its first Connection.
For more details, see “java.sql.Driver interface” in the Java DB Reference Manual.
Once the Derby JDBC driver class has been loaded, you can connect to any Derby
database by passing the embedded connection URL with the appropriate attributes to the
DriverManager.getConnection method.
For example:
Connection conn = DriverManager.getConnection(“jdbc:derby:sample”);
Portanto, pensei que o seguinte código por si só já deveria conectar ao banco de dados, já que o servidor já havia sido iniciado “embutido” na mesma jvm do programa.
try{
Connection con = DriverManager.getConnection(“jdbc:derby://localhost:1527/CRHDatabase”, “crh”, “crh”);
launch(CRHDatabaseApp.class, args);
}catch (Exception ex){
System.out.println("Erro na execução: " + ex.getMessage());
}
Porém, só funciona se eu conectar ao servidor manualmente !
O que devo fazer ?