0

I am looking for a way to programmatically start the H2 database service through java / command task.

For Windows: I can use the below command to start the service

java -jar C:/H2/h2/bin/h2-1.4.195.jar -tcpAllowOthers

From Java App, as described here: Start H2 database programmatically

Note: I utlizied the simple H2-DBManager Approach.

In both the cases, I see applications keep on running.

My expectation is: I need a way to start the H2 database programmatically and make it in run as a background process and move to the next step.

Also, I am looking for a way to embed postgres database into my ETL application and start it programmatically.

  • Only one question per question. Doing this for H2 will be very different then doing this for Postgres (which is not available as an "embedded" database) –  Jul 03 '17 at 11:54
  • H2 is the high priority . – Ashif Ahamed Jul 03 '17 at 13:40
  • So, you found the code and the command. You know what you want. What is your question? – tobi6 Jul 03 '17 at 14:06
  • My question is once I triggered the start the h2 database using command or through java, I am expecting the database service to up in background. Suppose if I trigger the command through command prompt , it remains at the same command like image : https://ibb.co/nifAQF. It should run background and allow us to type other commands in the same windows. – Ashif Ahamed Jul 03 '17 at 17:29

2 Answers2

0

If you use the command line on Windows, try adding an START at the beginning of the command:

START "" java -jar C:/H2/h2/bin/h2-1.4.195.jar -tcpAllowOthers

On Linux add an &

java -jar C:/H2/h2/bin/h2-1.4.195.jar -tcpAllowOthers &

tobi6
  • 8,033
  • 6
  • 26
  • 41
  • How to start H2 database programmatically and once triggered the start command and it need to switch to next step . It should not hang there ... – Ashif Ahamed Jul 04 '17 at 05:32
  • Sorry, I didn't understand this. What hangs? – tobi6 Jul 04 '17 at 09:17
  • Hangs means the java program remanis in the execution state like shown in the image https://ibb.co/cOZ3fF. Once execute , I want this java program to go for completion state.. – Ashif Ahamed Jul 04 '17 at 12:55
  • Ok, this is a different requirement. So you want to start it in the background, let it run *and end the background h2 process with your ending ETL job*. I am not sure if the solution I provided will help you in this case, since the START command just makes sure a command will be executed in the background. I think there is a `start_service.cmd` file, maybe use that and then call `stop_service.cmd`. – tobi6 Jul 04 '17 at 13:48
0

You can do in Talend by tSystem Component where you can write these command and execute the command by running the talend jobs. If your Job server or Talend Studio is installed on Windows then.

START "" java -jar C:/H2/h2/bin/h2-1.4.195.jar -tcpAllowOthers

If Job Server or Talend Studio is installed on Linux then

java -jar C:/H2/h2/bin/h2-1.4.195.jar -tcpAllowOthers &
Hitesh Mundra
  • 1,538
  • 1
  • 9
  • 13