[java] How to run H2 database in server mode?

How to start H2 database in server mode. I need to start it from my application.I tried the following code:

server = Server.createTcpServer().start();

Here is the properties for the connection:

javabase.jdbc.url = jdbc:h2:tcp://localhost:9092/nio:~/source/db/database/db;AUTO_SERVER=TRUE
javabase.jdbc.driver = org.h2.Driver
javabase.jdbc.username = sa
javabase.jdbc.password =

When I run the program I got the following error:

client.db.exception.DAOException: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-164]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:169)
    at org.h2.message.DbException.get(DbException.java:146)
    at org.h2.store.FileLock.getExceptionAlreadyInUse(FileLock.java:439)
    at org.h2.store.FileLock.lockFile(FileLock.java:336)
    at org.h2.store.FileLock.lock(FileLock.java:128)
    at org.h2.engine.Database.open(Database.java:542)
    at org.h2.engine.Database.openDatabase(Database.java:222)
    at org.h2.engine.Database.<init>(Database.java:217)
    at org.h2.engine.Engine.openSession(Engine.java:56)
    at org.h2.engine.Engine.openSession(Engine.java:159)
    at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
    at org.h2.engine.Engine.createSession(Engine.java:121)
    at org.h2.server.TcpServerThread.run(TcpServerThread.java:133)
    at java.lang.Thread.run(Thread.java:680)

Thanks,

This question is related to java database h2

The answer is


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to database

Implement specialization in ER diagram phpMyAdmin - Error > Incorrect format parameter? Authentication plugin 'caching_sha2_password' cannot be loaded Room - Schema export directory is not provided to the annotation processor so we cannot export the schema SQL Query Where Date = Today Minus 7 Days MySQL Error: : 'Access denied for user 'root'@'localhost' SQL Server date format yyyymmdd How to create a foreign key in phpmyadmin WooCommerce: Finding the products in database TypeError: tuple indices must be integers, not str

Examples related to h2

Spring Boot default H2 jdbc connection (and H2 console) auto increment ID in H2 database How to run H2 database in server mode? H2 database error: Database may be already in use: "Locked by another process" View content of H2 or HSQLDB in-memory database H2 in-memory database. Table not found Can I have H2 autocreate a schema in an in-memory database? Frontend tool to manage H2 database How to find rows in one table that have no corresponding row in another table