Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 238 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
H2 database error: Database may be already in use: "Locked by another process"

#11
answer for this question => Exception in thread "main" 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-161]

close all tab from your browser where open h2 database also Exit h2 engine from your pc
Reply

#12
I was facing this issue in eclipse . What I did was, killed the running java process from the task manager.

[![enter image description here][1]][1]


[1]:


It worked for me.
Reply

#13
For InteliJ: right lick on your database in the database view and choose "Disconnect".
Reply

#14
If you are running same app into multiple ports where app uses single database (h2), then add `AUTO_SERVER=TRUE` in the url as follows:

```
jdbc:h2:file:C:/simple-commerce/price;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE;AUTO_SERVER=TRUE
```
Reply

#15
In your **application.properties** file > edit the datasource into:

spring.datasource.url=jdbc:h2:file:C:/temp/test;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE

**Happy coding!**
Reply

#16
Identify the H2 process id and kill it. For mac

> ps -ef|grep h2

Then get the process id and kill it.

> kill -9 PID
Reply

#17
>I tried to delete the dbname.lock.db file but it is automatically re-created.
>How can I unlock the database to use it from my Java program?

Just add `FILE_LOCK=NO;`. `FILE_LOCK=NO` doesn't make `dbname.lock.db`.
```
spring.datasource.url=jdbc:h2:file:./testdb/h2;DB_CLOSE_ON_EXIT=false;FILE_LOCK=NO;
```

The detail for FILE_LOCK reference [this][1].
> Using the method NO forces the database to not create a lock file at all


[1]:

[To see links please register here]

Reply

#18
According [H2 Database Tutorial](

[To see links please register here]

) you can run the H2 Database in three different modes:

1. Server mode:

`jdbc:h2:tcp://localhost/~/test`

When using H2 db in server mode (also known as client/server mode) all data is transferred over TCP/IP. Before application can use H2 Database in server mode, you need to start the H2 DB within the same or another machine.

2. Embedded mode:

`jdbc:h2:~/test`

H2 db in embedded mode will be faster but the downside of it is that no other process can access the Database. In the above connection string, the Data will be saved into the ‘test’ folder, under the user’s home directory.

3. Mixed mode:

The mixed mode combines some features of the embedded and the server mode. The first application connecting to the H2 db does that in embedded mode, but at the same time it starts a server so that other applications can concurrently access the same data, even from different processes.

`jdbc:h2:/data/test;AUTO_SERVER=TRUE`

When using automatic mixed mode, you can share the JDBC URL for all applications using the DB. By default the server uses any free TCP port. The port can be set manually using AUTO_SERVER_PORT=9090.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through