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 trialDave Goodchild
1,141 PointsDoesn't seem to be establishing a connection, or something is up with the backend service that tries to execute the code
The following code just never
// Load class "org.sqlite.JDBC" Class.forName("org.sqlite.JDBC");
// Establish connection to database named "treehouse.db" try(Connection c = DriverManager.getConnection("jdbc:sqlite:treehouse.db")) {
} catch(SQLException ex) {
}
// Load class "org.sqlite.JDBC"
Class.forName("org.sqlite.JDBC");
// Establish connection to database named "treehouse.db"
try(Connection c = DriverManager.getConnection("jdbc:sqlite:treehouse.db")) {
} catch(SQLException ex) {
}
3 Answers
Dave Goodchild
1,141 PointsYou can see some examples of "try with resources" here: https://blogs.oracle.com/weblogicserver/using-try-with-resources-with-jdbc-objects
The problem is the Treehouse error that states: "Oh no! We didn't hear from the challenge service in a timely fashion!".
I've reported it to their support team. But in case anyone else comes by, the construct is valid and I'll report back here what they reply with.
John Lack-Wilson
8,181 PointsHey Dave, thanks for the question - the problem here is that try / catch blocks should look like this below:
try {
// Your code here - i.e. what you want to try to do
} catch (Exception exc) {
// Error handling code
}
I understand the way that the challenge has been set out makes it seem like you put your code within the try ( here), but try keyword should be followed by an opening curly brace.
Dave Goodchild
1,141 PointsThis construct is a "try with resources", the issue seems to be the actual connection is timing out and I'm receiving an error about the server process not executing in time.
John Lack-Wilson
8,181 PointsFair enough, but it did work for me when I put your code inside the try block.
Dave Goodchild
1,141 PointsDave Goodchild
1,141 PointsThe support team came back to inform me that there had been technical difficulties and that they were resolved by end of the day.