Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Importing a MySQL database


Java Database Integration with JDBC

with David Gassner

Video: Importing a MySQL database

Importing a MySQL database provides you with in-depth training on Developer. Taught by David Gassner as part of the Java Database Integration with JDBC
Expand all | Collapse all
  1. 5m 23s
    1. Welcome
    2. What you should know before starting this course
      1m 20s
    3. Using the exercise files
      3m 10s
  2. 12m 2s
    1. Testing your Java development environment
      5m 14s
    2. Importing a MySQL database
      5m 1s
    3. Creating a database user in MySQL
      1m 47s
  3. 32m 47s
    1. What is JDBC?
      4m 26s
    2. Choosing a JDBC driver
      6m 46s
    3. Connecting to a MySQL database server
      8m 7s
    4. Connecting to a HyperSQL database file
      6m 23s
    5. Executing a static SQL statement
      7m 5s
  4. 17m 42s
    1. Connecting to multiple databases
      6m 24s
    2. Handling JDBC exceptions
      7m 7s
    3. Closing database resources in Java 7
      4m 11s
  5. 47m 25s
    1. Looping through result sets
      8m 23s
    2. Moving the cursor in scrollable result sets
      5m 51s
    3. Limiting the number of fetched rows
      6m 57s
    4. Filtering data with prepared statements
      6m 58s
    5. Calling stored procedures
      5m 48s
    6. Handling multiple values from stored procedures
      5m 54s
    7. Using generic getter methods in Java SE 7
      7m 34s
  6. 45m 23s
    1. Managing data entities with JavaBean classes
      5m 0s
    2. Retrieving a single row as a JavaBean object
      6m 5s
    3. Inserting rows with prepared statements
      8m 2s
    4. Updating rows with prepared statements
      5m 4s
    5. Deleting rows with prepared statements
      4m 9s
    6. Managing data with updatable result sets
      6m 6s
    7. Using a persistent database connection
      6m 43s
    8. Committing and rolling back transactions
      4m 14s
  7. 9m 35s
    1. Getting the DatabaseMetaData object
      3m 40s
    2. Getting column and data type information
      5m 55s
  8. 50s
    1. Next steps

please wait ...
Watch the Online Video Course Java Database Integration with JDBC
Video Duration: 5m 1s2h 51m Intermediate Nov 28, 2012

Viewers: in countries Watching now:

View Course Description

Whether you're building a web- or desktop-based application with Java SE or Java EE, many Java applications need to integrate data from a relational database. This course describes how to read and manage data from relational databases such as MySQL and SQL Server using the Java Database Connectivity (JDBC) API.

Author David Gassner explains how to choose a JDBC driver and connect to one or more databases. He also provides detailed instructions on reading, selecting, and updating data; calling stored procedures; managing data via JavaBean classes or with prepared statements; and working with metadata.

Topics include:
  • Importing a MySQL database
  • Connecting to databases
  • Handling JDBC exceptions
  • Looping through result sets
  • Limiting the number of fetched rows
  • Filtering data with prepared statements
  • Calling stored procedures
  • Inserting, updating, and deleting rows with prepared statements
  • Using a persistent database connection
  • Committing and rolling back transactions
David Gassner

Importing a MySQL database

To follow along with the exercises in this course, you'll need a local installation of MySQL and a copy of phpMyAdmin, a web-based management system that lets you manage a MySQL Database. You can select from a number of approaches to installing this software on your computer. I describe how to install this software in the course installing Apache, MySQL, and PHP, which is a completely free course available in the online training library. In this course, I will describe how to install separate components on either Mac or Windows, or you can select from one of the many available software bundles which include Apache, MySQL, PHP, and phpMyAdmin.

These include WampServer for Windows, MAMP for Mac OS X, or XAMPP or BitNami, which are both available for both Windows and Mac. Throughout this course I'll be using MAMP, a software bundle specifically designed for use on Mac OS X. If you're using MAMP, there's one preferences thing you need to take care of. When you first install MAMP, you'll see that it's set ports of 8888 for Apache and 8889 for MySQL. It does this so you can run the copy of Apache included with the MAMP side by side with a copy of Apache included with the Mac.

But for this course, you'll need to run Apache and MySQL on their standard default ports. To do this, go to this Preferences dialog to the Ports tab and click Set to default Apache and MySQL ports, and you'll see that the my SQL port is set to the standard port of 3306. That's what Java and JDBC will expect. I'll click OK, wait for the servers to restart, and then click Open start page, and here I'll see that MySQL is running on the correct port of 3306.

If you're using any of the other configurations of Apache, MySQL, and PHP, this port should already be set for you. MAMP is the only software bundle that I'm aware of where you need to make this change. Now the next step, once you have confirmed that MySQL is running is to import a database that I'll be using throughout this course. I'll go to phpMyAdmin. If you're not sure where to find phpMyAdmin on your configuration, check the particular server bundle's documentation. Within phpMyAdmin, I'm going to create a database.

I'll go to the Databases tab, I'll click into the text box, and I'll type the name of the database I want to create, explorecalifornia. If you're following along, make sure that you spell the name of the database exactly this way, all lowercase and all one word, because all of the exercises throughout the course will expect it. Click Create, and now your database has been created. Now, I'm going to import an SQL script that's provided as part of the Free exercise files that accompany this course. I have copied by Free exercise files to the desktop, but you can find them wherever you installed them.

Within the Free exercise files there is a database folder, and within that folder there's an SQL file called exploreCalifornia.sql. This is a simple text file, and you can open it in any TextEditor. Within this SQL file there's a command to use explorecalifornia, the database that I have just created. And then the five tables that are a part of this database are dropped if they already exist. So if you want to refresh your database, you can just run this SQL script in the future, and it will delete all of the existing data and refresh the database table structure and content.

Little further down in the script, for each table there's a create statement that describes the structure of the database and a series of Insert statements that populate a table with data. There are tables named Admin, explorers, packages, tours, and states. And the states table has 50 rows. I'll close my TextEditor, and I'll return to phpMyAdmin. Now I'm ready to import my database. I'll click into the database and click the Import tab. I'll browse to select my SQL file.

I'll be sure to select the file with the file extension .sql. There are also files with extensions of .script and .properties, but those are for use with another Database Management System. I'll select the file and click Open, and then I'll scroll down to the bottom of the screen and click Go. If everything goes well, I'll see a message that the import has been successfully finished, and if I click into the database again I'll see my five tables have been created. For any of these tables, I can click into the name of the table. For example, I'll click into states, and I'll see the listing of all the data.

Just see the structure of the database table, including the names of the columns which is important to know when programming with JDBC. I'll click this Structure tab, and I can also click any of the other tabs to run SQL statements, Search, Insert data, Export, Import, and Execute other operations. So if you successfully followed through the steps, you'll have a working MySQL Server installation, and you'll have imported the sample database that I'll be using throughout this course.

There are currently no FAQs about Java Database Integration with JDBC.

Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Java Database Integration with JDBC.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts. provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now

A trusted source for knowledge.


We provide training to more than 4 million people, and our members tell us that helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.