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
Assim que vc chama o DriverManager.getConnection(), o HSQLDB já inicia de dentro do Java, em modo embutido.
cesalvador
Mano,
Mesmo que o banco de dados não esteja no ar ? :shock:
:roll:
danieldestro
IN-PROCESS(Standalone) MODEThismoderunsthedatabaseengineaspartofyourapplicationprograminthesameJavaVirtualMachine.Forsomeapplicationsthismodecanbefaster,asthedataisnotconvertedandsentoverthenetwork.Themaindrawbackisthatitisnotpossibletoconnecttothedatabasefromoutsideyourapplication.AsaresultyoucannotcheckthecontentsofthedatabasewithexternaltoolssuchasDatabaseManagerwhileyourapplicationisrunning.TherecommendedwayofusingthismodeinanapplicationistouseanHSQLDBServerinstanceforthedatabasewhiledevelopingtheapplicationandthenswitchtoIn-Processmodefordeployment.AnIn-ProcessModedatabaseisstartedfromJDBC,withthedatabasefilepathspecifiedintheconnectionURL.Forexample,ifthedatabasenameistestdbanditsfilesarelocatedinthesamedirectoryaswherethecommandtorunyourapplicationwasissued,thefollowingcodeisusedfortheconnection:Connectionc=DriverManager.getConnection("jdbc:hsqldb:testdb", "sa", ""); ThedatabasefilepathformatcanbespecifiedusingforwardslashesinWindowshostsaswellasLinuxhosts.Sorelativepathsorpathsthatrefertothesamedirectoryonthesamedrivecanbeidentical.ForexampleifyourdatabasepathinLinuxis/opt/db/testdbandyoucreateanidenticaldirectorystructureontheC: drive of a Windows host, you can use the same URL in both Windows and Linux:Connectionc=DriverManager.getConnection("jdbc:hsqldb:/opt/db/testdb", "sa", "");
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 ?