I am trying to run a scan-only workload using YCSB client on MySQL database (a 10GB setup). I am using the following command to run the workload
./bin/ycsb run jdbc -P workloads/workloademod -p db.driver=com.mysql.jd bc.Driver -p db.url=jdbc:mysql://localhost:3306/ycsbtest -p db.user=username -p maxscanlength=100 -p recordcount=5000 -p operationcount=1000 -p maxexecutiontime=1800 > try_ycsb_emod
But I get java GC out of memory exception and the workload gets killed as follows:-
Loading workload...
Starting test.
Maximum execution time specified as: 1800 secs
Exception in thread "Thread-1" java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3380)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3327)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1928)
at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3278)
at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:462)
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2997)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2245)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2638)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2530)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1907)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2030)
at com.yahoo.ycsb.db.JdbcDBClient.scan(JdbcDBClient.java:348)
at com.yahoo.ycsb.DBWrapper.scan(DBWrapper.java:107)
at com.yahoo.ycsb.workloads.CoreWorkload.doTransactionScan(CoreWorkload.java:605)
at com.yahoo.ycsb.workloads.CoreWorkload.doTransaction(CoreWorkload.java:491)
at com.yahoo.ycsb.ClientThread.run(Client.java:233)
Could not wait until max specified time, TerminatorThread interrupted.
I have tried increasing the java heap size for ycsb client by doing "export YCSB_HEAP_SIZE=8000" to make it 8G, still I get the same error.
I checked the mysql query that the ycsb client sends to mysql server and I don't see a reference/implication to the max_scan_length metric. Also, running this mysql query using a mysql client instead of the ycsb client works fine.
I am not sure what can I do to fix the same. Can someone help me out here?
Thanks,
Rene
It's a bug with the jdbc implementation:
https://github.com/brianfrankcooper/YCSB/issues/171
Related
I'm running Oracle 11GR2 on an Amazon RDS instance. occasionally I get an IO Error: Got minus one from a read call when making a call to DriverManager.getConnection(getUrl()) and I'm not sure why. Other applications work correctly.
To further confuse things, the error will correct itself on occasion (following next iteration of the program).
How should I approach a "Got minus one from a read call" error?
Full stack trace:
java.sql.SQLRecoverableException: IO Error: Got minus one from a read call
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at com.cwd.facile.db.Database.<init>(Database.java:44)
at com.cwd.facile.ns.NetSuiteRequestBased.<init>(NetSuiteRequestBased.java:29)
at com.cwd.facile.ns.CommonOperations.isInventoryItem(CommonOperations.java:205)
at com.cwd.facile.ns.CommonOperations.findItemIdByName(CommonOperations.java:188)
at com.cwd.facile.ns.CommonOperations.createSalesOrder(CommonOperations.java:970)
at com.cwd.facile.Main.main(Main.java:47)
Caused by: oracle.net.ns.NetException: Got minus one from a read call
at oracle.net.ns.Packet.receive(Packet.java:311)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:300)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
... 12 more
Database.java line 44: setConn(DriverManager.getConnection(getUrl()));
Other info:
I thought it was a bad JDBC url, but it does work, sometimes for days on end before failing.
Amazon RDS is a managed instance and configuration changes may not be possible
I am using ojdbc6.jar for connectivity
The immediate cause of the problem is that the JDBC driver has attempted to read from a network Socket that has been closed by "the other end".
This could be due to a few things:
If the remote server has been configured (e.g. in the "SQLNET.ora" file) to not accept connections from your IP.
If the JDBC url is incorrect, you could be attempting to connect to something that isn't a database.
If there are too many open connections to the database service, it could refuse new connections.
Given the symptoms, I think the "too many connections" scenario is the most likely. That suggests that your application is leaking connections; i.e. creating connections and then failing to (always) close them.
We faced the same issue and fixed it. Below is the reason and solution.
Problem
When the connection pool mechanism is used, the application server (in our case, it is JBOSS) creates connections according to the min-connection parameter. If you have 10 applications running, and each has a min-connection of 10, then a total of 100 sessions will be created in the database. Also, in every database, there is a max-session parameter, if your total number of connections crosses that border, then you will get Got minus one from a read call.
FYI: Use the query below to see your total number of sessions:
SELECT username, count(username) FROM v$session
WHERE username IS NOT NULL group by username
Solution: With the help of our DBA, we increased that max-session parameter, so that all our application min-connection can accommodate.
I got this error message from using an oracle database in a docker despite the fact i had publish port to host option "-p 1521:1521". I was using jdbc url that was using ip address 127.0.0.1, i changed it to the host machine real ip address and everything worked then.
I would like to augment to Stephen C's answer, my case was on the first dot. So since we have DHCP to allocate IP addresses in the company, DHCP changed my machine's address without of course asking neither me nor Oracle. So out of the blue oracle refused to do anything and gave the minus one dreaded exception. So if you want to workaround this once and for ever, and since TCP.INVITED_NODES of SQLNET.ora file does not accept wildcards as stated here, you can add you machine's hostname instead of the IP address.
I had a similar issue when running Oracle 21c XE image on Docker locally when I was trying to connect to it by localhost or 127.0.0.1.
The fix was to log in into the container and modify sqlnet.ora in the following way:
echo "DISABLE_OOB=ON" >> /opt/oracle/oradata/dbconfig/XE/sqlnet.ora
and restart the container.
in my case, I got the same exception because the user that I configured in the app did not existed in the DB, creating the user and granting needed permissions solved the problem.
Cause
oracle binary permission issue ($ORACLE_HOME/bin/oracle)
[tst19c#exa033dbadm01 bin]$ $ORACLE_HOME/bin
[tst19c#exa033dbadm01 bin]$ ls -ltr oracle
-rwxr-s--x 1 tst19c asmadmin 446528768 May 3 14:28 oracle
Action Taken
[tst19c#exa033dbadm01 bin]$ chmod 6751 oracle
[tst19c#exa033dbadm01 bin]$ ls -ltr oracle
Now
-rwsr-s--x 1 tst19c asmadmin 446528768 May 3 14:28 oracle
[tst19c#exa033dbadm01 bin]$
Did any of you had this below error when trying to connect to H2?
The release I'm using is 1.4.199, on windows, with TAFJFuctions.
First I run this command:
java -server -cp h2-1.4.199.jar;C:\Users\...\H2\TAFJFunctions.jar org.h2.tools.Server -web -tcp -tcpPort 9092 -tcpAllowOthers -baseDir C:\Users\...\H2\bin
and I've got connected with TCP server running and Web Console server running as well.
Then I've run this command:
SET H2URL=jdbc:h2:tcp://locaLhost/t24db;DB_CLOSE_ON_EXIT=FALSE;MODE=Oracle;TRACE_LEVEL_FILE=0;TRACE_LEVEL_SYSTEM_OUT=0;FILE_LOCK=NO;IFEXISTS=TRUE;CACHE_SIZE=8192;MVCC=TRUE;LOCK_TIMEOUT=60000
And then this command:
java -server -cp h2-1.4.199.jar;C:\Users\...\H2\TAFJFunctions.jar org.h2.tools.Shell -url %H2URL% -driver org.h2.Driver -user t24 -password t24
And here I've got the below error:
"Exception in thread "main" org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/.../H2/bin/t24db" not found, and IFEXISTS=true, so we cant auto-create it [90146-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:617)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
at org.h2.message.DbException.get(DbException.java:205)
at org.h2.message.DbException.get(DbException.java:181)
at org.h2.engine.Engine.openSession(Engine.java:67)
at org.h2.engine.Engine.openSession(Engine.java:201)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:178)
at org.h2.engine.Engine.createSession(Engine.java:161)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:160)
at java.lang.Thread.run(Unknown Source)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:617)
at org.h2.engine.SessionRemote.done(SessionRemote.java:607)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:143)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:431)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:317)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:169)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:148)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.h2.tools.Shell.runTool(Shell.java:148)
at org.h2.tools.Shell.main(Shell.java:81)"
Any idea how to get this working?
Thank you,
Carina
With IFEXISTS=TRUE the problem is oblivious, but without this parameter or with attempt to set it to FALSE situation is not going to be changed.
All recent versions of H2 database don't allow remote (including local TCP connections) database creation by default any more due to security reasons. When it is allowed, everyone who can connect to your port can create a new database, get ADMIN privileges in it and therefore get the same access to your system as your JVM and your user account allows.
Unfortunately, H2 1.4.199 throws a confusing error message, it was improved only in 1.4.200 and in this version (when IFEXISTS=TRUE wasn't used) the error message is “Database … not found, either pre-create it or allow remote database creation (not recommended in secure environments)”.
If you use a TCP (or Pg/ODBC) server you need to create your databases in some other way before you try to connect to them with networked protocol.
For example, you can open the JDBC connection (DriverManager.getConnection()) with embedded URL and close it immediately.
You can replace org.h2.tools.Server with org.h2.tools.Console and you'll see another http connection URL (if you start it from the command line), something like http://127.0.0.2:8082?key=12c58e1c5f9ce1ae88a2921f74e7655ed91a80746730cc6bfa8d4bbb464f69ee; with this URL you will be able to create the database from the web interface (only if remove web interface is not enabled).
You can also add the -tool parameter (only to Console, the Server doesn't support it) to get H2 Console icon in the system tray, its context menu has a command to create a new database and this icon can also open the web interface with the same security key. Don't share this key with anyone. It will be different on each restart, however.
You can also use the command-line Shell tool.
https://h2database.com/html/tutorial.html#creating_new_databases
In the worst case you can enable the remove database creation, but it is not really secure even with local connections and it is completely insecure when remote connections are enabled as in your case. You will have a well-known remote security hole in your system, I don't think that it is your intention.
The problem here is that there is no database called t24db already.
In the property spring.datasource.url property which you use to connect to h2, remove the parameter IFEXISTS=TRUE.
This will ensure that the database is created if it does not exist.
I'm running Oracle 11GR2 on an Amazon RDS instance. occasionally I get an IO Error: Got minus one from a read call when making a call to DriverManager.getConnection(getUrl()) and I'm not sure why. Other applications work correctly.
To further confuse things, the error will correct itself on occasion (following next iteration of the program).
How should I approach a "Got minus one from a read call" error?
Full stack trace:
java.sql.SQLRecoverableException: IO Error: Got minus one from a read call
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at com.cwd.facile.db.Database.<init>(Database.java:44)
at com.cwd.facile.ns.NetSuiteRequestBased.<init>(NetSuiteRequestBased.java:29)
at com.cwd.facile.ns.CommonOperations.isInventoryItem(CommonOperations.java:205)
at com.cwd.facile.ns.CommonOperations.findItemIdByName(CommonOperations.java:188)
at com.cwd.facile.ns.CommonOperations.createSalesOrder(CommonOperations.java:970)
at com.cwd.facile.Main.main(Main.java:47)
Caused by: oracle.net.ns.NetException: Got minus one from a read call
at oracle.net.ns.Packet.receive(Packet.java:311)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:300)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340)
... 12 more
Database.java line 44: setConn(DriverManager.getConnection(getUrl()));
Other info:
I thought it was a bad JDBC url, but it does work, sometimes for days on end before failing.
Amazon RDS is a managed instance and configuration changes may not be possible
I am using ojdbc6.jar for connectivity
The immediate cause of the problem is that the JDBC driver has attempted to read from a network Socket that has been closed by "the other end".
This could be due to a few things:
If the remote server has been configured (e.g. in the "SQLNET.ora" file) to not accept connections from your IP.
If the JDBC url is incorrect, you could be attempting to connect to something that isn't a database.
If there are too many open connections to the database service, it could refuse new connections.
Given the symptoms, I think the "too many connections" scenario is the most likely. That suggests that your application is leaking connections; i.e. creating connections and then failing to (always) close them.
We faced the same issue and fixed it. Below is the reason and solution.
Problem
When the connection pool mechanism is used, the application server (in our case, it is JBOSS) creates connections according to the min-connection parameter. If you have 10 applications running, and each has a min-connection of 10, then a total of 100 sessions will be created in the database. Also, in every database, there is a max-session parameter, if your total number of connections crosses that border, then you will get Got minus one from a read call.
FYI: Use the query below to see your total number of sessions:
SELECT username, count(username) FROM v$session
WHERE username IS NOT NULL group by username
Solution: With the help of our DBA, we increased that max-session parameter, so that all our application min-connection can accommodate.
I got this error message from using an oracle database in a docker despite the fact i had publish port to host option "-p 1521:1521". I was using jdbc url that was using ip address 127.0.0.1, i changed it to the host machine real ip address and everything worked then.
I would like to augment to Stephen C's answer, my case was on the first dot. So since we have DHCP to allocate IP addresses in the company, DHCP changed my machine's address without of course asking neither me nor Oracle. So out of the blue oracle refused to do anything and gave the minus one dreaded exception. So if you want to workaround this once and for ever, and since TCP.INVITED_NODES of SQLNET.ora file does not accept wildcards as stated here, you can add you machine's hostname instead of the IP address.
I had a similar issue when running Oracle 21c XE image on Docker locally when I was trying to connect to it by localhost or 127.0.0.1.
The fix was to log in into the container and modify sqlnet.ora in the following way:
echo "DISABLE_OOB=ON" >> /opt/oracle/oradata/dbconfig/XE/sqlnet.ora
and restart the container.
in my case, I got the same exception because the user that I configured in the app did not existed in the DB, creating the user and granting needed permissions solved the problem.
Cause
oracle binary permission issue ($ORACLE_HOME/bin/oracle)
[tst19c#exa033dbadm01 bin]$ $ORACLE_HOME/bin
[tst19c#exa033dbadm01 bin]$ ls -ltr oracle
-rwxr-s--x 1 tst19c asmadmin 446528768 May 3 14:28 oracle
Action Taken
[tst19c#exa033dbadm01 bin]$ chmod 6751 oracle
[tst19c#exa033dbadm01 bin]$ ls -ltr oracle
Now
-rwsr-s--x 1 tst19c asmadmin 446528768 May 3 14:28 oracle
[tst19c#exa033dbadm01 bin]$
We are running a web service in Apache Tomcat in Amazon Linux. Initially web-service is running properly. We are getting too many open files exception after making more than 1000 web request. Again this issue will be resolved when we re start the tomcat server.
Please find below the Exception
25-Apr-2016 10:05:52.628 SEVERE [http-nio-8080-Acceptor-0] org.apache.tomcat.util.net.NioEndpoint$Acceptor.run Socket accept failed
java.io.IOException: Too many open files
at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:686)
at java.lang.Thread.run(Thread.java:745)
PS : we are not doing any file related operations in the web service .
It looks like, that there is some limit on open files. As you are running on Linux I suspect you are running out of file descriptors.
Check out ulimit command to see the number of allowed opened files.
ulimit -n
You can change the number of open files by editing:
/etc/security/limits.conf
and adding something like this:
* soft nofile 4096
* hard nofile 4096
You can check more about limits.conf here.
The default limit is 1024 and can be too low for some Java applications.
More information about increasing the maximum number of open files in this article: http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
Although if "ulimit" is raised at some point down the line tomcat stops causing same error.
So in order to avoid this you can check list of open files for the application user on Linux using command "lsof -u username" or simply "lsof" and see if code related files are open ( eg..properties files ) if so kill those specific files using # kill -9 lsof -t -u username command for that specific tomcat user.
You need to fix your code to load those files writing simply in a static block of your classes. So that only one file loads even if multiple hits are made by any number of users.
Now you can re check after deploying new changes with the same lsof command and see. Only one file will be seen. This will permanently fix your issue without raising the ulimit each time
That is because socket connections are treated as files, so that means you have too many connections opened. Check the limitations (each OS has different policy about it - same goes for each server), how many ports you can open at same time, etc. You can use NIO to limit those things.
I am trying to use the H2 database from a Java application.
I created the database and its tables through the H2 Console and then I try to connect from Java using
Connection con = DriverManager.getConnection("jdbc:h2:~/dbname", "username", "password");
However I receive the following error:
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]
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?
H2 is still running (I can guarantee it). You need to use a TCP connection for multiple users such as ->
<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/C:\Database\Data\production;"/>
OR
DriverManager.getConnection("jdbc:h2:tcp://localhost/server~/dbname","username","password");
It also means you need to start the server in TCP mode. Honesetly, it is pretty straight forward in the documentation.
Force kill the process (javaw.exe for Windows), and make sure that any application that might have started it is shut down. You have an active lock.
I had the same problem.
in Intellj, when i want to use h2 database when my program was running i got the same error.
For solve this problem i changed the connection url from
spring.datasource.url=jdbc:h2:file:~/ipinbarbot
to:
spring.datasource.url=jdbc:h2:~/ipinbarbot;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
And then my problem gone away. now i can connect to "ipinbarbot" database when my program is.
If you use Hibernate, also don't forget to have:
spring.jpa.hibernate.ddl-auto = update
goodluck
I'm using h2db with a test T24 tafj application, I had the same problem but I managed to resolve it by identifying the application that is running h2 (launched when I attempted to setup a database connection).
ps aux|grep java
will give output as:
sysadmin 22755 3.2 0.1 5189724 64008 pts/3 Sl 08:28 0:00 /usr/java/default/bin/java -server -Xmx2048M -XX:MaxPermSize=256M -cp h2-1.3.175.jar:/r14tafj/TAFJ/dbscripts/h2/TAFJFunctions.jar org.h2.tools.Server -tcp -tcpAllowOthers -baseDir /r14tafj/t24/data
now kill this with its process id:
kill -9 22755
and at last remove the lock file:
rm -f dbname.lock.db
I got clue from Saman Salehi above.
My usecase:
Preparing REST application for client-side load balancing(running two JVM instances of REST). Here my MVC application will call this REST application that has ActiveMQ backend for DATA.
I had the problem when I ran two instances of REST application in eclipse and trying to run both instances at the same time with the following configuration
spring.datasource.url=jdbc:h2:file:./Database;
spring.jpa.properties.hibernate.hbm2ddl.auto=update
After adding DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
spring.datasource.url=jdbc:h2:file:./Database;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE
Both instances are running and showing in Eureka dasboard.
Don't close the database when the VM exits : jdbc:h2:;DB_CLOSE_ON_EXIT=FALSE
Multiple processes can access the same database without having to start the server manually ;AUTO_SERVER=TRUE
Further reading:
http://www.h2database.com/html/features.html
You can also visit the "Preferences" tab from the H2 Console and shutdown all active sessions by pressing the shutdown button.
Simple step: Go to the task manager and kill the java process
then start your apllication
You can also delete file of the h2 file database and problem will disappear.
jdbc:h2:~/dbname means that file h2 database with name db name will be created in the user home directory(~/ means user home directory, I hope you work on Linux).
In my local machine its present in: /home/jack/dbname.mv.db I don't know why file has a name dbname.mv.db instead a dbname.
May be its a h2 default settings.
I remove this file:
rm ~/dbname.mv.db
OR:
cd ~/
rm dbname.mv.db
Database dbname will be removed with all data. After new data base init all will be ok.
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
I ran into similar problems running with ORMLite from a web application. I initially got stuck on the syntax to use server mode in the url. The answers above helped with that. Then I had the similar user/password error which was easier to figure out. I did not have to shut anything down or erase any files. The following code worked:
protected ConnectionSource getConnectionSource() throws SQLException {
String databaseUrl = "jdbc:h2:tcp://localhost/~/test";
return new JdbcConnectionSource(databaseUrl,"sa","sa");
}
To use H2 in server mode on wildfly, I Modifed connection-url in standalone.xml
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool- name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:tcp://localhost/~/test</connection-url>
…
</datasource>
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
According H2 Database Tutorial you can run the H2 Database in three different modes:
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.
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.
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.
Ran into a similar issue the solution for me was to run fuser -k 'filename.db' on the file that had a lock associated with it.
Hope this helps!
I was facing this issue in eclipse . What I did was, killed the running java process from the task manager.
It worked for me.
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!
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
For InteliJ: right lick on your database in the database view and choose "Disconnect".
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.
Using the method NO forces the database to not create a lock file at all