Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Hibernate Basics Persisting Data with Hibernate Updating and Deleting Entities

Can the H2 database be accessed via a terminal?

Is it possible to view the database created using Hibernate via the terminal?


2 Answers

Alexander Nikiforov
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,174 Points

No, I think it is not possible.


Postgresql and Sqlite and others have that feature I think, but not H2 database.

H2 has a nice GUI feature.

Have you watched Chris 'Spring with Hibernate' video:


In this video, Chris starts his database as a server database, so URL should be different.

But for testing purposes, and if you are beginner, it is better to fire up server base database.

So your hibernate.cfg.xml should be changed to

        <!-- Database connection setting -->
        <property name="connection.driver_class">org.h2.Driver</property>

       <!-- server based database -->
        <property name="connection.url">jdbc:h2:tcp://localhost/./data/contactmgr</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.H2Dialect</property>

        <!-- Update the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>

        <!-- Show the queries prepared by Hibernate -->
        <property name="show_sql">true</property>

        <!-- Names the annotated entity classes -->
        <mapping class="com.teamtreehouse.contactmgr.model.Contact" />

You can also see GUI for embedded database by running java -jar h2*.jar, but it can be problematic with embedded databases because, embedded databases allow ONLY one connection, i.e. you cannot use database in your Java Application and simultaneously use GUI to see your database.

Anyway. All information is here:


And please watch Chris video, disregard Spring details, just see how he fires up H2 database GUI console

Thank you!