Reputation: 86847
I have a simple h2 database example, I assume it is a database that is stored in a single file. But where do I find this file? I'd like to connect to that db using SQL clients like Squirrel. Where is this file placed by default?
<property name="eclipselink.jdbc.platform"
value="org.eclipse.persistence.platform.database.H2Platform" />
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:~/myDB;FILE_LOCK=NO" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="sa" />
Upvotes: 2
Views: 14547
Reputation: 983
You can use the following code to run H2 in server mode and connect using SQuirrl SQL client.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:target/h2/ps;AUTO_SERVER=TRUE" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
You can use SQuirrel SQL client (http://squirrel-sql.sourceforge.net/) to connect to you H2 database and look at the tables.
Create new connection. Select H2 in the driver dropdown menu Set url to your project target folder h2 folder (jdbc:h2:C:\projects\workspace\TestProject\target/h2/ps;AUTO_SERVER=true) Enter user name ("sa") Enter password ("")
Upvotes: 3
Reputation: 11841
Based on the following value:
jdbc:h2:~/myDB;FILE_LOCK=NO"
It appears that your database file is located in your home directory in a file called myDB
The ~
denotes your home directory.
Upvotes: 4
Reputation: 9639
In your example the file is placed in the file myDB under your home (represented as ~ ) directory :
<property name="javax.persistence.jdbc.url" value="jdbc:h2:**~/myDB**;FILE_LOCK=NO" />
Upvotes: 0