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

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,159 Points

Started the Hibernate course. Same error message as a student in 2019. The workspace needs an update. No one's home.

Following the video to make the database. The code is correct (checked several times.) Nothing happens (the database is not created) except this. The community does not seem to be active, and the instructor is apparently no longer at Treehouse. No one is there to help anymore. This was once a wonderful community; now it's a ghost town. I'll move on for now, but I had hoped to take and complete this course.

Java Public class JdbcMain {
  public static void main(String[] args) throws ClassNotFoundException {
    // TODO: Load the SQLite JDBC driver (JDBC class implements java.sql.Driver)
    Class.forName("org.sqlite.JDBC")

    // TODO: Create a DB connection
    try(Connection connection = DriverManager.getConnection("jdbc:sqlite:contactmgr.db")) {

      // TODO: Create a SQL statement

      //Statement statement = connection.createStatement();

     // statement.executeUpdate("DROP TABLE IF EXISTS contact"));



      // TODO: Create a DB table

      // TODO: Insert a couple contacts

      // TODO: Fetch all the records from the contacts table

      // TODO: Iterate over the ResultSet & display contact info

    } catch (SQLException ex) {
      // Display connection or query errors
      System.err.printf("There was a database error: %s%n",ex.getMessage());
    }
  }

}

Error message: Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m

3 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hi there Nancy Melucci ! 👋

Are you referring to this video? Save a Java Object to a Database? I believe this is the first video in the Hibernate Basics course that uses this Workspace.

Picked up JAVA_TOOL_OPTIONS: -Xmx128m                                                                                            
Picked up _JAVA_OPTIONS: -Xmx128m

Is actually not an error it's just output from the Workspace that didn't happen at the time of Chris filming this course. I believe they had to make changes on the back end of java Workspaces after some time to have more memory allocated and this is just a normal output that you can ignore. They mention it in other Java courses but not this one, apologies there for the confusion.

I followed along with this video in it's entirety and didn't have any issues and am seeing the desired output (after those JAVA_TOOLS outputs, of course) by the end of the video.

Are you seeing any other errors after running your code at the end of the video? I'm also not seeing the 2019 post you're referring to, so I'm hoping I have the correct video here. Please let us know! With how fast things change in the tech world, it can be hard to catch everything immediately, but always double check the Teacher's Notes below each video, this is where any caught updates / fixes will be noted 👍

I hope you have been able to continue on without any issues 😃

Nancy Melucci
Nancy Melucci
Courses Plus Student 36,159 Points

I will go in, try again, ignore the output and see what happens. I'll post here one way or the other. Thanks!

Nancy Melucci
Nancy Melucci
Courses Plus Student 36,159 Points

I was traveling, so I did not have a chance to try the Hibernate course again. I tried again today, and I believe my code is correct (I've checked it and debugged it). Nevertheless, the same message is given when I try to create the contacts table in the first section:

Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m

No table is created. After debugging, no error message is generated to help the programmer figure out the problem.

I tried to print a message to the console to see if something else was happening. It appears that this workspace needs updating. I am including my code below in case my thickheadedness is causing the issue.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import java.util.List;
import java.util.ArrayList;

public class JdbcMain {
  public static void main(String[] args) throws ClassNotFoundException {
    // TODO: Load the SQLite JDBC driver (JDBC class implements java.sql.Driver)

   System.out.print("SPLUNGE");

    Class.forName("org.sqlite.JDBC");

    // TODO: Create a DB connection
    try(Connection connection = DriverManager.getConnection("jdbc:sqlite:contactmgr.db")) {
      Statement statement = connection.createStatement();

      statement.executeUpdate("DROP TABLE IF EXISTS contacts");
      statement.executeUpdate("CREATE TABLE contacts(id INTEGER PRIMARY KEY, firstname STRING, lastname STRING, email STRING, phone INT(10))");

      statement.executeUpdate("INSERT INTO contacts (firstname, lastname, email, phone) VALUES('Hannah', 'Houston', 'hhouston@hmail.com', 7145551212)");
      statement.executeUpdate("INSERT INTO contacts (firstname, lastname, email, phone) VALUES('Joe', 'Blow', 'blowme@hmail.com', 7135551212)");

       ResultSet rs = statement.executeQuery("SELECT * FROM contacts");


                              while(rs.next()) {

                                int id = rs.getInt("id");
                                String firstName = rs.getString("firstname");
                                String lastName = rs.getString("lastname");

                                System.out.printf("%s %s (%d)", firstName, lastName, id);


                              }    

    } catch (SQLException ex) {
      // Display connection or query errors
      System.err.printf("There was a database error: %s%n",ex.getMessage());
    }

}
}
Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

I'm still going off of this video Save a Java Object to a Database, if you're referring to a later video please let me know. But this is the code I have that works for me at the end of this video

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import java.util.List;
import java.util.ArrayList;

public class JdbcMain {
  public static void main(String[] args) throws ClassNotFoundException {
    // TODO: Load the SQLite JDBC driver (JDBC class implements java.sql.Driver)
    Class.forName("org.sqlite.JDBC");

    // TODO: Create a DB connection
    try(Connection connection = DriverManager.getConnection("jdbc:sqlite:contactmgr.db")) {

      // TODO: Create a SQL statement
      Statement statement = connection.createStatement();

      // TODO: Create a DB table
      statement.executeUpdate("DROP TABLE IF EXISTS contacts");
      statement.executeUpdate("CREATE TABLE contacts (id INTEGER PRIMARY KEY, firstname STRING, lastname STRING, email STRING, phone INT(10))");

      // TODO: Insert a couple contacts
      Contact c = new Contact("Taco", "Man", "taco@man.com", 5555555551L);
      save(c, statement);
      c = new Contact("Gunner", "Boi", "gunner@goodboi.com", 5555555552L);
      save(c, statement);

      // TODO: Fetch all the records from the contacts table
      ResultSet rs = statement.executeQuery("SELECT * FROM contacts");

      // TODO: Iterate over the ResultSet & display contact info
      while(rs.next()) {
        int id = rs.getInt("id");
        String firstName = rs.getString("firstname");
        String lastName = rs.getString("lastname");
        System.out.printf("%s %s (%d)%n", firstName, lastName, id);
      }

    } catch (SQLException ex) {
      // Display connection or query errors
      System.err.printf("There was a database error: %s%n",ex.getMessage());
    }
  }

  public static void save(Contact contact, Statement statement) throws SQLException {
    String sql = "INSERT INTO contacts (firstname, lastname, email, phone) VALUES('%s', '%s', '%s', %d)";
    sql = String.format(sql, contact.getFirstName(), contact.getLastName(), contact.getEmail(), contact.getPhone());
    statement.executeUpdate(sql);
  }
}

As far as I can tell, it's what he has at the end of the video as well. The commands I ran to get the desired output are what he ran as well.

javac JdbcMain.java
java -cp sqlite-jdbc-3.6.8.jar:. JdbcMain

and my output...

Picked up JAVA_TOOL_OPTIONS: -Xmx128m                                                                                            
Picked up _JAVA_OPTIONS: -Xmx128m                                                                                                
Taco Man (1)                                                                                                                     
Gunner Boi (2)   

I'm sorry I didn't have the time to really dissect why the difference of my having the save() method made that big of a difference, I will look into this further tomorrow, but I wanted to at least give you this while I was on so that you can continue on with the material. I hope this helps!

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,159 Points

I got it to run. I still don't see the database created (in the file system). We'll see what happens next.