MySql JDBC Driver & How to Connect
DbSchema is connecting to MySql using JDBC Drivers.
- What are JDBC Drivers
- What is the JDBC URL
- Download the MySql JDBC Driver
- How to Connect using the DbSchema MySql
What are JDBC Drivers?
JDBC drivers are Java library files with the extension ‘.jar‘, used by Java applications to connect to the database.
Usually they are provided by the same company which developed the database software.
DbSchema is an MySql Client which already includes
the MySql JDBC driver. DbSchema can configure the MySql JDBC URL and test the connectivity.
What is the JDBC URL?
The URL is a string (text) with a specific format containing information about the host where the database is running, the port, username, database name, etc.
The URL format is specific to each driver.
Any wrong character in the URL may make the database connectivity fail.
Therefore we recommend installing DbSchema and try to get connected, and you will find the JDBC URL in the connection dialog.
- Required File(s): mysql-connector-java-nn-bin.jar
- Java Driver Class: com.mysql.jdbc.Driver
- URL: jdbc:mysql://HOST[:PORT][/DB]
- Website: MySQL
Download the MySql JDBC Driver
The driver library files are compressed in a zip archive.
If you cannot connect, or you get issues with the driver, please ask DbSchema Team for help.
Solving Common Connectivity Issues
Enable Remote Access on MySql Server
By default MySql does not allow connecting from another machine as the one where the server is installed.
You can enable remote access during installation ( see the next chapter ) or later using the instructions below.
- On the server type in the command prompt or terminal mysql -u root -p <root_password>
The mysql console should start. - List the databases using show databases
- View the configured grants using select * from db;
- Enable remote access for a user foo using GRANT ALL ON foo.* TO bar@’202.54.10.20′ IDENTIFIED BY ‘PASSWORD’;
Here you have to edit the user ( put your user instead of foo ), the IP of the client machine and the root password.
If this didn’t help, please try to search the web for tutorials.
MySql Installation Tips
Install MySql from http://www.mysql.com. During installation go for a detailed install,
and when you are prompted for the user password check the ‘Enable root access from remote machines’.
Enabling this you will be allowed to connect to MySql from another computer.
Remember the password you set here, it will be requested when connecting to the database as user root.
Connect to MySql using DbSchema
DbSchema is using JDBC Drivers to connect to the database. Installing the application you can easy set up a connection.
DbSchema will build the JDBC URL for you.
- 1
Download DbSchema. DbSchema has a free community edition.
No email or registration is required. - 2
Choose to connect to the database, and choose MySql.
- 3
At this point, DbSchema already downloads the JDBC driver into this folders:
- C:\Users\YourUser\.DbSchema\drivers\MySql (Windows) or
- /Users/YourUser/.DbSchema/drivers/MySql (Linux and MacOS).
In the Connection Dialog, select the driver and the JDBC URL template.
For databases using multiple possibilities to connect, may exists multiple templates.
Choose if the database is running on the current machine or a different port.
If is running on a different machine (remote), you need to find the host name.
Hover the Host info label using the mouse to get instructions. - 4
Press the Ping button to test the connectivity. - 5
In the URL combo there is an option to ‘Manually Edit the URL’.
Select this option to see the generated JDBC URL. - 6
After connecting, DbSchema will create the first diagrams (layouts). Double-click any table header or column to edit. - 7
Activate the SQL Editor from the menu to edit and execute queries.
For a detailed list of features, please read the DbSchema Quick Tour.
MySQL Connector/J
MySQL provides connectivity for client applications developed in the Java programming language with MySQL Connector/J, a driver that implements the Java Database Connectivity (JDBC) API and also MySQL X DevAPI.
MySQL Connector/J 8.1 is a JDBC Type 4 driver that is compatible with the JDBC 4.2 specification. The Type 4 designation means that the driver is a pure Java implementation of the MySQL protocol and does not rely on the MySQL client libraries.
The driver also contains an implementation of MySQL X DevAPI, an application programming interface for working with MySQL as a Document Store through CRUD-based, NoSQL operations.
For more information, please visit the official MySQL Connector/J documentation.
Licensing
Please refer to the README and LICENSE files, available in this repository, and the Legal Notices in the MySQL Connector/J documentation for further details.
Getting the Latest Release
MySQL Connector/J is free for usage under the terms of the specified licensing and it runs on any operating system that is able to run a Java Virtual Machine.
Download and Install
MySQL Connector/J can be installed from pre-compiled packages that can be downloaded from the MySQL Connector/J download page. Installing MySQL Connector/J only requires obtaining the corresponding JAR file from the downloaded bundle or installer and including it in the application’s CLASSPATH.
According to how you use MySQL Connector/J, you may also need to install the following third-party libraries on your system for it to work:
- Protocol Buffers (protobuf-java) is required for using X DevAPI
- Oracle Cloud Infrastructure SDK for Java (oci-java-sdk) is required to support OCI AIM authentication
- Simple Logging Facade API (slf4j-api) is required for using the logging capabilities provided by the default implementation of org.slf4j.Logger.Slf4JLogger by MySQL Connector/J
As a Maven Dependency
Alternatively, MySQL Connector/J can be obtained automatically via Maven’s dependency management by adding the following configuration in the application’s Project Object Model (POM) file:
<dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>8.1.0</version> </dependency>
MySQL Connector/J’s own Project Object Model (POM) file specifies a transitive dependency to Protocol Buffers (protobuf-java) since it is required for using X DevAPI. However, if you do not use the X DevAPI features, you may also want to add a dependency exclusion to avoid linking the unneeded sub-library. For example:
<dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>8.1.0</version> <exclusions> <exclusion> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> </exclusion> </exclusions> </dependency>
Build From Source
This driver can also be complied and installed from the source available in this repository. Please refer to the MySQL Connector/J documentation for detailed instructions on how to do it.
GitHub Repository
This repository contains the MySQL Connector/J source code as per the latest release. No changes are made in this repository between releases.
Contributing
There are a few ways to contribute to the MySQL Connector/J code. Please refer to the contributing guidelines for additional information.
Additional Resources
- MySQL Connector/J Developer Guide.
- MySQL Connector/J X DevAPI Reference.
- MySQL Connector/J, JDBC and Java forum.
#connectors
channel in MySQL Community Slack. (Sign-up required if you do not have an Oracle account.)- @MySQL on Twitter.
- MySQL Blog.
- MySQL Connectors Blog archive.
- MySQL Newsletter.
- MySQL Bugs Database.
For more information about this and other MySQL products, please visit MySQL Contact & Questions.
- Details
- Written by
- Last Updated on 02 March 2022 | Print Email
This post lists resources to download JDBC drivers for common databases, for your reference in database programming with Java.
You know, in order for Java applications working with a database engine via Java Database Connectivity (JDBC), an appropriate JDBC driver library is required to be available in the application’s classpath. A JDBC driver library consists of Java classes which implement low-level communication with the database engine. It talks with Java applications via JDBC API and usually bundled as a JAR or ZIP file.
For your reference and convenience, this article provides a summary of JDBC driver download for common databases including MySQL, SQL Server, Oracle, PostgreSQL, Apache Derby (Java DB), SQLite, H2 and Microsoft Access. If you use Maven, see the Maven dependencies for those JDBC drivers below.
In the table below, click on the download link corresponding to the database you want to download its JDBC driver JAR file:
Database |
JDBC Driver Provider |
JAR file name |
Download |
MySQL |
Oracle Corporation |
mysql-connector-java-VERSION.jar |
Download JDBC Driver for MySQL |
SQL Server |
Microsoft Corporation |
sqljdbc41.jar, sqljdbc42.jar |
Download JDBC Driver for SQL Server |
Oracle |
Oracle Corporation |
ojdbc6.jar, ojdbc7.jar, ojdbc8.jar |
Download JDBC Driver for Oracle (login required) |
PostgreSQL |
The PostgreSQL Global Development Group |
postgresql-VERSION.jar |
Download JDBC Driver for PostgreSQL |
Apache Derby |
Apache Software Foundation |
derby.jar, derbyclient.jar |
Download JDBC Driver for Apache Derby |
SQLite |
Xerial.org |
sqlite-jdbc-VERSION.jar |
Download JDBC Driver for SQLite |
H2 |
h2database.com |
h2-VERSION.jar |
Download JDBC Driver for H2 Database |
Microsoft Access |
UCanAccess.com |
ucanaccess-VERSION.jar |
Download JDBC Driver for Microsoft Access |
NOTES:
- Some drivers come as JAR files (Oracle, PostgreSQL), so you can add the JAR files directly to your application’s classpath.
- Some drivers come as zipped bundles (MySQL, SQL Server), so you have to extract the bundles and copy the appropriate JAR file (as specified in the above table) to your application’s classpath.
- There is a distribution of Apache Derby comes with JDK 7 called Java DB. So if you are using JDK 7, you can use the jar files directly from JDK_HOME\db\lib directory without downloading Apache Derby. However, Java DB is removed from JDK since Java 8.
Maven Dependencies for JDBC Drivers
If your Java project uses Maven, simply add the following dependency in the pom.xmlfile.
Maven Dependency for MySQL JDBC Driver:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> </dependency>
Maven Dependency for Microsoft JDBC driver for SQL Server:
<dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>8.2.1.jre11</version> </dependency>
Maven Dependency for Oracle JDBC Driver:
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc8</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>d:/Path/To/Oracle/ojdbc8-full/ojdbc8.jar</systemPath> </dependency>
NOTE: Due to Oracle’s license restriction, you must manually download Oracle JDBC driver and use system dependency like that.
Maven Dependency for PostgreSQL JDBC Driver:
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.2.jre7</version> </dependency>
Maven Dependency for SQLite JDBC Driver:
<dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.21.0.1</version> </dependency>
Maven Dependency for Apache Derby JDBC Driver:
<dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>10.14.2.0</version> </dependency>
Maven Dependency for H2 JDBC Driver:
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>2.1.210</version> </dependency>
Maven Dependency for Microsoft Access JDBC Driver:
<dependency> <groupId>net.sf.ucanaccess</groupId> <artifactId>ucanaccess</artifactId> <version>4.0.4</version> </dependency>
NOTE: The versions of the dependencies listed above may not be up to date. You can search on Maven Central Repository for the latest versions.
Related JDBC Tutorials:
- JDBC Database Connection URLs
- How to connect to a database with JDBC
- JDBC CRUD Tutorial
- JDBC Transaction Tutorial
- How to call stored procedure with JDBC
- How to read database metadata in JDBC
- How to insert binary data into database with JDBC
- How to read binary data from database with JDBC
- How to use Scrollable ResultSet
- How to use Updatable ResultSet
- How to use CachedRowSet
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.
Add comment
This article will tell you what MySQL JDBC driver is and how to download and install it in your window. JDBC drivers are the Java files with the extension that allow using all the Java applications in order to connect to the database. It allows users to connect with live MySQL data directly from the application to connect with JDBC. It quickly generates and organizes powerful Java application that assimilates with MYSQL compatible database engine.
MySQL JDBC Driver Review
MYSQL provides the driver for JDBC which is the standard-based driver. It also provides net enabling developers to build an application in their choice of language. But the native C library helps the developer implant this driver into their application. If the application is created for internal use . its slow performance leads to the project’s failure.
So this driver helps in better performance. While accessing information from remote sources creates many network connectivity problems, service delays, and disconnection, these create the problem and lower your performance. Still, this driver solves all of these problems through powerful smart coaching techniques that can help in reducing the latency issues and also help in improving your performance.
Features Of JDBC MySQL
- MySQL JDBC Driver has very interesting features; some of them are given below.
- It is highly flexible; it is speedy.
- Unified integration with a custom application, reporting, and ETL tool
- It is easily scalable. It can handle a huge amount of data, more than 50 million rows.
- Data, parameters, and metadata have full Unicode support.
- This driver supports the operating system of 32 and 64 bits.
- For access to data, it connects to the MySQL data
- It allows a developer to give high productivity.
- It is independent of the platform as it can download, install, and operates in almost every operating system.
- Easily connect with the relational database server, MariaDB, Google Cloud SQL, and many more.
MySQL JDBC Download For Windows
For downloading the latest version of the MySQL JDBC Driver for Windows, follow the following instructions: The straightforward steps for downloading the application are available. You can see the DOWNLOAD button at the bottom of this page; click on the button and download it.
Next, you can get the downloaded zip file; now, you have to unzip this archive file by using win zip for the window. Then locate that driver inside your achieve file. Now you have to install the setup to run it on your PC. While downloading, if you face any difficulty or any issues, kindly let us know, and we will guide you.
Also Check: MYSQL CONNECTOR JAVA
How To Install JDBC Driver On PC Windows?
For installing the driver in your window, follow the following instructions:
The first step is that you have to log in to the server hosting web help desk. Then, navigate to the target directory. If you are running 12.6 and below the web help desk, direct towards the web help desk, go to bin than JRE, go to the library, and finally go to the extension.
But if you are running1,7 or later web help desk, there is a little different process for navigation / first go to the web help desk then go to bin and then web apps, and then helpdesk then WEB-INF finally go to lib.
After that, copy your driver file into the lib directory. After all these steps are done, restart the web help desk. Now your driver is installed in the window. The whole installation process after downloading is error-free. However, if you face any problem while downloading or installing the setup, you are most welcome to write down the problem you are facing in the comment box to solve it.
How do I install JDBC Driver For MySQL on a macOS system?
For installing the driver in your macOS system, follow the following instructions:
- The first step is that you have to log in to the server hosting web help desk.
- Then, navigate to the target directory. If you are running 12.6 and below the web help desk, direct towards the web help desk, go to bin than JRE, go to the library, and finally go to the extension.
- But if you are running1,7 or later web help desk, there is a little different process for navigation / first, go to the web help desk then go to the bin, and then web apps, and then helpdesk WEB-INF finally go to lib.
- After that, copy your driver file into the library directory. After all these steps are done, restart the web help desk. Now your driver is installed in the macOS system.
You may also like: SELENIUM CHROMEDRIVER
FAQs about MySQL JDBC Driver
Is MySQL database free?
It is open-source and free software, and it is licensed software.
What is the use of MySQL JDBC Driver?
It provides connections for the client application that are developed in the Java programming language. It allows using of all the Java applications in order to connect to the database. This allows their users to connect with live MySQL data directly from the application which allows them to connect with JDBC. It quickly generates and organizes a powerful Java application that assimilates with the MYSQL-compatible database engine.
How can I Determine the Version of the JDBC Drive?
You can easily determine the version of the driver that you have installed on your PC by using the get driver version method.
Is this driver flexible to use?
Yes, it is very flexible to use as it supports numerous embedded applications. Also, it is very compatible and runs many operating systems that are off 32 and 64 bits.
If you are using Java applications alongside various different databases, then you must also need the respective Java Database Connectivity (JDBC) driver. A driver is a critical component in the bigger schemes that allows one component to be able to communicate with another. In this case, allowing a Java application to communicate with the database.
This article lists down how and from where you can download the JDBC drivers for the following databases:
- MySQL
- SQL Server
- Oracle
- PostgreSQL
- Apache Derby (Java DB)
- SQLite
- H2
- Microsoft Access
Table of contents
- What is Java Database Connectivity (JDBC) Driver
- Download JDBC Drivers
- Download JDBC Driver for MySQL
- Download JDBC Driver for SQL Server
- Download JDBC Driver for Oracle
- Download JDBC Driver for PostgreSQL
- Download JDBC Driver for Apache Derby
- Download JDBC Driver for SQLite
- Download JDBC Driver for H2 Database
- Download JDBC Driver for Microsoft Access
- Maven Dependencies for JDBC Drivers
- Closing Words
What is Java Database Connectivity (JDBC) Driver
As we already mentioned, the JDBC driver is used to allow Java applications to be able to communicate with different databases. It uses the JDBC API initially developed by Sun Microsystems as a means to use a standard method to access data in a variety of databases.
This technology now belongs to Oracle.
The JDBC drivers allow you to write one application that can send SQL statements to different data sources.
There are 4 different types of JDBC drivers:
- JDBC-ODBC bridge driver
- Native-API driver (partially java driver)
- Network Protocol driver (fully java driver)
- Thin driver (fully java driver)
Each of these driver types has its advantages and disadvantages. However, that is not what we will be discussing in this post.
Download JDBC Drivers
Refer to the below sections to download the respective JDBC drivers.
Note: Some drivers are downloaded as JAR files, which need to be added directly to your application’s classpath. While some drivers come as zipped bundles, which need to be extracted and then copy the appropriate JAR file to your application’s classpath.
Download JDBC Driver for MySQL
-
Open MySQL Community Downloads page.
-
Select your operating system and then click Go to download page.
Select OS -
Click on the Download button for the preferred JDBC driver download.
Click download -
On the next page, click “No thanks, just start my download,” and your download should then begin automatically.
Begin download
Download JDBC Driver for SQL Server
-
Open the page for JDBC driver download for SQL Server.
-
Under the Download section, click on the link that you want to download (ZIP and TAR.GZ). Clicking the link will begin the download instantly.
Begin download
Download JDBC Driver for Oracle
-
Open the Oracle Database JDBC driver and Companion Jars Downloads page.
-
From here, you can download the regular JDBC drivers or the Long Term Release JDBC drivers for Oracle. Click on the respective link for the version that you want to download, and it should begin downloading instantly.
Download regular JDBC driver for Oracle Download Long Term Release JDBC driver for Oracle
Download JDBC Driver for PostgreSQL
-
Open the PostgreSQL JDBC drivers download page.
-
Here, click on the links under the Current version section to begin downloading the latest JDBC driver for PostgreSQL.
Begin download Alternatively, you can also download older versions of the drivers from the given table below.
Download older versions
Download JDBC Driver for Apache Derby
-
Start by navigating to the downloads page for the JDBC driver for Apache Derby.
-
Here, click on the version that you want to download.
Select version -
On the next page, under the Distributions section, click on the type and format of download you want to get for the JDBC driver, and your download should then begin automatically.
Begin download
Download JDBC Driver for SQLite
-
Open the GitHub page for SQLite JDBC driver.
-
Here, click Code, and then click Download ZIP to download a compressed folder with the JDBC driver.
Download driver -
Now extract the downloaded driver and then copy the appropriate JAR file to your application’s classpath.
Download JDBC Driver for H2 Database
-
Open the H2 Database JDBC drivers download page.
-
Now simply click on the link below the Downloads section to begin downloading the JDBC driver for the H2 database.
Begin download
Download JDBC Driver for Microsoft Access
-
Open the Microsoft Access JDBC drivers download page.
-
Here, click on the link that you want to download.
Start download -
You will now be redirected to the next page where your download should begin automatically in the next few seconds.
This is how you can install the JDBC drivers for the respective databases. However, if your project uses Maven, then you will need to make a few changes to the POM.XML file as well.
Maven Dependencies for JDBC Drivers
In case your project uses Maven, add the respective piece of code to the POM.XML file.
Note: The versions of the dependencies listed in the code below may not be up to date. You can search on Maven Central Repository for the latest versions.
-
Maven dependency for MySQL JDBC driver
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> </dependency>
-
Maven dependency for Microsoft JDBC driver for SQL Server
<dependency> <groupId>com.microsoft.sqlserver</groupId> <artifactId>mssql-jdbc</artifactId> <version>8.2.1.jre11</version> </dependency>
-
Maven dependency for Oracle JDBC Driver
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc8</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>d:/Path/To/Oracle/ojdbc8-full/ojdbc8.jar</systemPath> </dependency>
-
Maven dependency for PostgreSQL JDBC Driver
<dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.2.2.jre7</version> </dependency>
-
Maven dependency for SQLite JDBC Driver
<dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.21.0.1</version> </dependency>
-
Maven dependency for Apache Derby JDBC Driver
<dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>10.14.2.0</version> </dependency>
-
Maven dependency for H2 JDBC Driver
<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>2.1.210</version> </dependency>
-
Maven dependency for Microsoft Access JDBC Driver
<dependency> <groupId>net.sf.ucanaccess</groupId> <artifactId>ucanaccess</artifactId> <version>4.0.4</version> </dependency>
Closing Words
The JDBC drivers are not for everyone, but only for those developers who need to make their applications communicate with various types of databases. If you are one of those, we certainly hope that this article helped you find the right drivers for your project.