From the course: Java Database Access with Hibernate
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Java application - Java Tutorial
From the course: Java Database Access with Hibernate
Java application
- [Instructor] At this point, we've created our configuration file. We used reverse engineering to create our mapping file, the message.hbm.xml. We created our class file, the message.java, which is what you see here. Now, I want to go back to my main program, where I'm going to ask the user to enter in a message. I'll read that message in, and then I'm going to establish a session with the database using hibernate, and then, save my message to the database. At the end of the program, I'll just print out all the messages that exist in the database, which should grow as we run the program multiple times. Because the whole point of this activity was to allow us to persist the messages from one session to the next, from one execution of our program to the next. So we run it a few times, we should see a few messages. All right, let's go over to the HelloWorldExample.java, which right now is just a template, an empty shell, and we're going to add information that we need. We're going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.