Join David Gassner for an in-depth discussion in this video Connecting to a MySQL database server, part of Java Database Integration with JDBC.
- View Offline
The first thing to learn in working with JDBC is how to connect to a database.…I'm going to start with MySQL.…To connect to MySQL, you'll need a Java driver, and you can get a free driver from mysql.com/downloads.…On this screen, scroll down to the Connector section and look for Connector/J.…You can get the most recent version of Connector/J from this website.…But to make this very easy, I have included a copy of the driver in the free exercise files that accompany the course.…
Go to the Free exercise files, to the libs folder, and locate them mysql jar file and…copy it to the clipboard.…Now go to Eclipse and open this project, ConnectMySQL from the exercise files.…If you don't have access to the exercise files, create a new Java project, add this class…to the package com.lynda.javatraining.db and type in the code that you see here.…That creates three constants named USERNAME, PASSWORD, and CONN_STRING.…Now I'm going to add the MySQL driver to my project.…
I'll right-click on the project in the Package Explorer, and I'll create a new folder.…
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.
- 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