FULL COURSE: Spring MVC and Hibernate (200+ videos)
This Hibernate tutorial series will help you quickly get up to speed with Hibernate.
DOWNLOAD SOURCE CODE for Hibernate tutorial.
View more videos on the playlist, Hibernate Tutorial: https://goo.gl/UKAdaq
Follow luv2code for more Hibernate tutorials:
If you liked my Hibernate tutorial, then join my mailing list: Get exclusive access to new Java tutorials.
Questions or problems about this Hibernate tutorial? Post them in the comments section below.
Want to suggest a video for my Hibernate tutorial? Leave a comment below. I'm always looking for new video ideas.
Let me know what video you'd like for me to create for this Hibernate tutorial.
Hibernate Tutorial Transcript
In this video, we're going to test our JDBC connection.
In the previous video, we did a lot of work with downloading JAR files. What I want to do hear is just do a very simple test to make sure that our JDBC connection works just fine. What we're going to do is create a very simple JDBC program, just to test everything out, just to make sure everything works out okay.
What I would like to do, is move into this hibernate tutorial under the source. I'll create a new package. Right click, I'll say New Package. The actual name of the package, I'll call it com.luv2code.jdbc. Once you're happy with that package name, go ahead and click on finish.
Now what I would like to do is actually create a new class. Again, right click on that package name. I'll say New Class. The actual name that I'll use for this class, I'll call it Testjdbc. Just very simple, and to the point. I'll also check the low item here for public static void, just so I can have a main method for this program. Then again, hit on Finish.
All right, great. We have a very basic program here and let's go ahead and dig in. Let's start writing some code.
I have a very simple try catch block. I have catch exception EXC. I'll do the EXC.print stack trace in case something goes wrong. Hopefully not. What I'll do is I'll just set up some variables here for my database connection information.
First off, I'll set up my JDBC URL. I'll call it JDBC:mysequel:localhost3306/ I give the name of my database scheme, which is hbstudenttracker. Here I'll say use SSL=false. Just so that I don't get that pesky SSL warning that my sequel introduced recently, which is really annoying. Anyway, use SSL will make that go away.
All right, so that's how JDBC URL, our user ID that we created, and we did all this stuff in previous slides here. Our user is HBStudent. We have this very secure system where our password is the same as our username. Only for training purposes, right? Okay, good. All right, so our URL, user ID, and password, great. We can use this information to actually give us a connection to a database.
All right. Here, I'm just mentioning again that use SSL as equals false as to get rid of that pesky my sequel SSL warnings.
All right, great. Let's go ahead and write some code here. I'm going to make use of my driver manager to get a connection. I'll also do some system out print lines here to tell myself what's going on here. All right, so I'll say system out print line, connecting to database. I'll just drop in that JDBC URL. Then I'll attempt to get a connection. Here I'll say connectionmycon=, and then I say driver manager.getconnection. I pass in my JDBC URL, my user ID, and my password. If that works out fine, then we have a successful connection. I can print a statement here saying connection successful.
I like to have fun with this stuff.
All right, so that's the piece there. Now, we need to fix some of our imports here. I can just click on this red X. We need to do that import on java.sql, so choose the second option here. Import Connection, and java.sql. Select that item. Yeah, that takes care of the item then. We should be good to go here.
All right, so just some very basic code here to test out our database connection. Let's go ahead and run this application. I just do a right click, Run As, Java Application. Then it's going to fire up, and say connection successful. Let me expand this window here, so you can see everything. Connecting to database, connection successful. This is great. This is just a confirmation that we have the correct URL, user ID, and password. Also, more importantly, is that JDBC driver that we have on our lib directory, is associated with our class path. Know that we can get a valid connection.
[Snip] for complete transcript, select More ... Transcript
This is the end of the Hibernate tutorial transcript.
Hi. In my case this code ("jdbc:mysql://localhost:3306/hb_student_tracker?useSSL=false") did not work. I found solution. I use this code ("jdbc:mysql://localhost:3306/hb_student_tracker?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC") which I found in internet, and its run.
Do you have any clue, what was the reason?
Can you please help me in solving this error...as shown below.
This is My code....
connecting to database:jbdc:mysql://localhost:3307/hb_student_tracker?useSSl=false
java.sql.SQLException: No suitable driver found for jbdc:mysql://localhost:3307/hb_student_tracker?useSSl=false
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
PLEASE HELP ME IN SOLVING THIS...
minor typo in your jdbc url
Make note of the first four characters ... should say "jdbc"
let me know if that clears it for you.
sorry for continuous comments frm me...
i got this error ... i even searched in google ..but didnt get the appropriate 1.
java.sql.SQLException: No suitable driver found for jdbc.mysql//localhost:3306/hb_student_tracker?useSSL=false
A couple of things:
1. Make sure the MySQL JDBC driver is configured in your Eclipse project's build path
2. Make sure your Hibernate configuration use the correct driver name
The solution code is available for download. source code and configuration files are included in the download. compare your code and configs to the solution to make sure you are not missing anything.
let me know your results.
Looking for someone like-minded? Chances are you’ve already got one thing in common.
15,000 New members.
Soulmates sees over 15,000 new faces every month.
#1 Customer service.
Feel safe and secure, with help from our award-winning customer service team.
Recently joined Soulmates.
Meet some of our latest members.
Online Dating Success Stories.
Intrepid explorers who’ve found the person of their dreams.
Kristian & Zoe.
"We met through Soulmates four years ago. Although were both based in London, the chances of us meeting by other means were slim. We just got married! Zoe is the most wonderful woman Ive ever met, and I know we are going to have an extremely happy life together."
Laura & Phil.
"Phil and I got married just over a year after we met on my first ever internet date through Guardian Soulmates. Weve been recommending the site to friends ever since. Thank you!" (Photography credit to Michael OSullivan)
Robin & Alec.
"I just wanted to let you know that you have another success story! My boyfriend, who I met via your site about two years ago, just proposed and we are getting married next year. THANK YOU!"
Alex & Rosie.
"Rosie and I met through Soulmates and were married in October, just 17 months later. Were wonderfully happy together!"
How does it work?
Find your Soulmate in three easy steps.
Register your free account today.