Iniciar banco de dados HSQL

Pessoal,

Estou fazendo um teste em um banco de dados em Java e hoje tenho um “BAT” para iniciar o banco, mas gostaria de iniciar pela minha aplicação. Como posso fazer isto ? :?:

Arquivo “BAT”

java -cp hsql.jar org.hsqldb.Server -database teste

Obrigado, :smiley:

CES

Assim que vc chama o DriverManager.getConnection(), o HSQLDB já inicia de dentro do Java, em modo embutido.

Mano,

Mesmo que o banco de dados não esteja no ar ? :shock:

:roll:

[code]IN-PROCESS (Standalone) MODE

This mode runs the database engine as part of your application program in the same Java Virtual Machine. For some applications this mode can be faster, as the data is not converted and sent over the network. The main drawback is that it is not possible to connect to the database from outside your application. As a result you cannot check the contents of the database with external tools such as Database Manager while your application is running. The recommended way of using this mode in an application is to use an HSQLDB Server instance for the database while developing the application and then switch to In-Process mode for deployment.

An In-Process Mode database is started from JDBC, with the database file path specified in the connection URL. For example, if the database name is testdb and its files are located in the same directory as where the command to run your application was issued, the following code is used for the connection:

Connection c = DriverManager.getConnection ("jdbc:hsqldb:testdb", "sa", "");

The database file path format can be specified using forward slashes in Windows hosts as well as Linux hosts. So relative paths or paths that refer to the same directory on the same drive can be identical. For example if your database path in Linux is /opt/db/testdb and you create an identical directory structure on the C: drive of a Windows host, you can use the same URL in both Windows and Linux:

Connection c = DriverManager.getConnection ("jdbc:hsqldb:/opt/db/testdb", "sa", "");[/code]

Para mais, leia a documentação:
http://hsqldb.sourceforge.net/web/hsqlDocsFrame.html

Valeu mano !!! :smiley: :smiley: :smiley: :stuck_out_tongue:

Meu, desculpe incomodar. :oops:

Mas o comando "Connection c = DriverManager.getConnection (“jdbc:hsqldb:/opt/db/testdb”, “sa”, “”); " so executa em Standalone, desta forma não consigo que outro usuário tenha acesso. Procurei na documentação e não encontrei de como fazer como Server, você sabe ? :smiley:

Valeu… :lol:

Tem lá na mesma documentação. Dá uma procurada.