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 Hibernate Basics Data Persistence & ORMs Using Java to Connect to a Database

What if I'm using mysql server and workbench instead of mysql lite?

Hi, I am trying to connect a project of mine to java. However since in the video mysql lite was used. Will it be a different procedure if I were to connect it to a mysql server?? If so..how will I connect it?

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

First of all, wait until you actually get to Hibernate.

Chris in this stage has not yet shown you why and how to use ORM.

So I strongly recommend not to do use the code he shown with actual databases.

When you will finish the course, please check the following link.

http://www.concretepage.com/hibernate-4/hibernate-4-annotation-example-with-gradle

It will help you to set up MySQL database with your Java Application.

The thing that will be different when you switch from SQlite to MySQL will be "url" and "driver class name".

// was for SQLite
Class.forName("org.sqlite.JDBC")
Driver.getConnection("jdbc:sqlite:contactmgr");

// to, for MySQL
Class.forName("com.mysql.jdbc.Driver")
Driver.getConnection("jdbc:mysql:contactmgr")

But Again, don't think too much, before you get to end of the course and learn how to set up with Gradle.

For now on video, is really just for learning purposes