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

Michael Switzer
Michael Switzer
7,490 Points

500 Internal Error when posting

When I tried to use Postman and send the POST request, I kept getting a 500 Internal Server Error. Looking at the logs, it looks like the H2 server isn't starting

1 Answer

Michael Switzer
Michael Switzer
7,490 Points

I went through the debugger step by step and watched the values as the database connection was established when I noticed that it was parsing the INIT with a space at the beginning " INIT" and that's when it kicked me into the exception methods. I went back to the line in Api.java and removed the space.

Line as given in the class:

Sql2o sql2o = new Sql2o("jdbc:h2:~/reviews.db; INIT=RUNSCRIPT from 'classpath:db/init.sql'", "", "");

Line that worked:

Sql2o sql2o = new Sql2o("jdbc:h2:~/reviews.db;INIT=RUNSCRIPT from 'classpath:db/init.sql'", "", "");