H2 Database


Other Databases

How do I set up H2 Database?

  1. Download the Platform Independent Zip version of the latest STABLE H2.
  2. Extract it to a directory of your choosing.
  3. At the h2 directory, create a startup.bat for PCs or startup.sh for Macs with the following commands:
    java -cp bin/h2*.jar org.h2.tools.Server -baseDir . -properties "bin" -web -webPort 8086 -webAllowOthers -tcpPort 9096 -tcp -tcpAllowOthers -tcpPassword 123 
  4. At the h2 directory, create a shutdown.bat for PCs or shutdown.sh for Macs with the following commands:
    java -cp bin/h2*.jar org.h2.tools.Server -tcpShutdown tcp://localhost:9096 -tcpPassword 123
  5. Open CommandPrompt/Terminal, navigate to your H2 directory, and start the startup.bat for PCs or startup.sh for Macs
  6. Open up H2 Console
  7. Fill the fileds with following informations:
    • Setting Name: BatTutorial
    • Driver Class: org.h2.Driver
    • JDBC URL: jdbc:h2:tcp://localhost:9096/sample/testDB
    • User Name: sa
    • Password: 123
    save the setting and then click 'connect'.
  8. Enter the following command and click 'run' to reset the database.
    DROP ALL OBJECTS 
  9. From Eclipse, under the sql folder, open up the CreateTables.sql file. Copy all the commands and paste into the console and click 'run'.
  10. Click on 'clear' to clear the console. Now your database is ready for use.
  11. Start the shutdown.bat for PCs or shutdown.sh for Macs to close the database when done using.
  12. Make sure the startup file is running before using the database.