Link to home
Start Free TrialLog in
Avatar of peterjim11
peterjim11

asked on

How to start the HSQLDB server only if it is not starting in the batch file?

Question:

I want to run the server start command only if it is not starting.

The following command will start the HSQLDB server. But how to check if it is start already?
Thanks.

@echo off
REM Start the database connection
START "Connect database" java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb
Avatar of forrestoff
forrestoff

The following will check the error level returned from the find command, and the command "net start" will show the list of services currently running"

I hope this works for you.  Let me know if you have questions.

Dave
@echo off
REM Start the database connection
net start|find /n /i "Connect database"
IF %ERRORLEVEL% == 1 echo Service not started.  Starting service...
else goto return
START "Connect database" java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb
:return

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of forrestoff
forrestoff

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peterjim11

ASKER

Your solution works. Thanks a lots, forrestoff.