[JAVA] How to create a database for H2 Database anywhere
Introduction h1>
System default when creating a new H2DB database
JDBC URL: jdbc: h2: ~ / test (C: \ Documents and Settings \ [username] \ test)
This is a solution when you want to create a directory directly under the C drive that can be accessed directly, but it does not work.
This time I would like to create a database named "test" in the "C: \ data" directory.
Solution 1 h1>
From the H2 console, enter "jdbc: h2: C: \ data \ test" in JDBC URL: and click Connect
![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/664939/b92121b1-fe6d-b90a-404e-e57a707c5df6.png)
- You may be able to create a database with Solution 1, but you may not be able to create it due to a strange error.
Solution 2 (when Solution 1 is not good) h1>
![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/664939/84e1a159-9962-cd36-749e-c152703534e8.png)
"Show hidden indicators" at the bottom right of the desktop
→ Right-click on "H2 Database Engine"
→「Create a new database...」
![3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/664939/2e755c7e-e887-0d58-8c5b-2cf95d15c3d9.png)
Database path:「C:\data\test」
Click Create
- Password: is required to be entered, so enter an appropriate one.
Conclusion h1>
![4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/664939/3b127fe9-5220-81f1-379f-e8632034060c.png)
Database created
Supplement h1>
![5.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/664939/3a5620ab-5461-7215-62a5-3f545109d347.png)
If you use Solution 2, you can delete the password by executing this SQL command after connecting to the database.
「ALTER USER sa SET PASSWORD '';」