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! While you're at it, check out some resources Treehouse students have shared here.

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 Spring with Hibernate Integrating Hibernate with Spring Add JPA Annotations to Entities

Unable to see the tables created in the H2 console

I am unable to see the tables created in the H2 console. Dont know if they are created at the right jdbc url. When i downloaded the starter project I saw the url as this: giflib.db.url = jdbc:h2:mem:giflib

My data folder is at the following location: E:\giflib-hibernate-master\data

So what should be my url?

2 Answers

Robert Goddard
Robert Goddard
15,019 Points

After pulling my hair out over this one, I figured it out. I assumed the ~ represented the "*nix" version of home, which it does; but it also works in windows. So my database is in c:\Users\rob\IdeaProjects\giflib-hibernate\data\giflib . Thus here is what the app.properties line should look like lib.db.url = jdbc:h2:tcp://localhost/~/IdeaProjects/giflib-hibernate/data/giflib ... I queried what java considered my "home (~)" directory by writting a tiny program that does this:

psvm { System.out.println(System.getProperty("user.home")); }

this'll at least tell you where the ~ is starting from... I think. Mine happened to be C:\Users\rob

Maira Kotsovoulou
Maira Kotsovoulou
2,146 Points

In your db url if you add two slashes after localhost, for example jdbc:h2:tcp://localhost//IdeaProjects/GifLib/data/giflib , you can refer to an absolute path in your disk and not under your home directory!