Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,039 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!