![]() The Shell tool we used also took us to the SQL prompt, so we could do something useful with that connection. This is another file-based URL, where the tilde (~) stands for your user’s home directory.įor convenience, we created our database using a file-based URL - which created a local database connection. In various H2 examples and tutorials, you may see a URL such as this: The above URL is a file-based URL - you could also have used the following, by including the optional “file:” segment: This storage structure replaced the previous B-tree based store as of version 1.4.177 (in 2014). mv part of that name refers to the storage type, used by default, when a new database is created - namely, “MVStore” - or “multi-version store”. This is the database.Īs already noted, the above example creates a file called: my_new_db.mv.db You will also see a new file in your directory, with a. We won’t be using the SQL prompt in this walkthrough, so you can type exit to quit it. Note the forward slashes, for Java’s benefit.įor all the other prompts you can accept the default value (just hit enter to continue).Īt the end of the process you will see a welcome message, and a SQL> prompt. URL: ignore the default value (if there is one) and enter the absolute path of the directory, followed by a name for your new database.Īssuming I created my new directory here… You will be presented with a series of prompts, with default values provided: Open a Windows command prompt and move to your new directory containing the JAR file. To create a new, empty H2 database, we will use one of the tools bundled with the JAR file. On the H2 Downloads page, there is a Windows installer which you are welcome to use, but for now we will simply download the self-contained JAR file: There are various ways to install and run Java - all outside the scope of this post. I will create a “server mode” database, since that is probably the most familiar model for people who have used a more mainstream relational database (Oracle, SQL Server, MySQL, etc.) in the past.īecause H2 is a pure-Java database, I will assume you already have a recent version of Java SE installed, and that you have a %JAVA_HOME% environment variable (for Windows) or $JAVA_HOME (for Linux). I will walk through the basics of creating a new H2 database on a Windows machine - the commands for Linux are pretty much the same (it’s all Java-based). ![]() The Tutorial and Features pages are also great places to start - and keep the Database URL Overview handy - that is probably the one area which may initially confuse new users. Read all about it here: H2 Database Engine It’s a small, fast, self-contained pure-Java relational database engine. In some of my other recent posts, I use the H2 database engine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |