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.
What is the JDBC URL?
The JDBC Driver requires the JDBC URL to know where the database is located ( on which machine and port), the database name or other settings.
All this are passed as a string, specific for each database and driver.
Download the MySql JDBC Driver
- Required File(s): mysql-connector-java-nn-bin.jar
- Java Driver Class: com.mysql.jdbc.Driver
- JDBC 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.
Communities
A collaborative platform to connect and
grow with like-minded Informaticans across the globe
Connect and collaborate with Informatica experts and champions
Have a question? Start a Discussion and get immediate answers you are looking for
Customer-organized groups that meet online and in-person. Join today to network, share ideas,
and get tips on how to get the most out of Informatica
Knowledge Center
Troubleshooting documents, product
guides, how to videos, best practices, and more
One-stop self-service portal for solutions, FAQs, Whitepapers, How Tos, Videos, and more
Video channel for step-by-step instructions to use our products, best practices, troubleshooting
tips, and much more
Information library of the latest product documents
Best practices and use cases from the Implementation team
Learn
Rich resources to help you leverage full
capabilities of our products
Role-based training programs for the best ROI
Get certified on Informatica products. Free, Foundation, or Professional
Free and unlimited modules based on your expertise level and journey
Resources
Library of content to help you leverage
the best of Informatica products
Most popular webinars on product architecture, best practices, and more
Product Availability Matrix statements of Informatica products
Monthly support newsletter
Informatica Support Guide and Statements, Quick Start Guides, and Cloud Product Description
Schedule
End of Life statements of Informatica products
To ensure compliance with MySQL licensing restrictions, the MySQL Java Database Connectivity (JDBC) driver is no longer bundled with WHD.
If your deployment is connected to a MySQL database (which is used by certain asset discovery connections), download the MySQL JDBC driver from the MySQL Community Downloads website.
After you unpack the ZIP or TAR archive, install the driver on your Windows, macOS, or Linux system.
See the MySQL website for instructions on connecting to MySQL using the JDBC driver.
The lowest version you can run in your WHD deployment is Connector/J 5.1.27. Be aware that SolarWinds does not support this connector.
Beginning with WHD 12.7.1, Oracle Java is replaced with the Open Java Development Kit (OpenJDK)—a free and open-source implementation of the Java Platform. This update modifies the directory structure where the MySQL JDBC driver is installed. To prevent errors after an upgrade, install the driver on your host server as described below. To install the MySQL JDBC Driver in versions prior to WHD 12.7.1, see the WHD Administrator Guide for the previous version.
Download the driver
The following procedures explain how to download the driver for WHD servers running MySQL 5.7 and MySQL 8.0. Select the procedure based on your configuration.
Download the driver for MySQL 5.7
-
Navigate to the MySQL Community Downloads website. located at:
https://dev.mysql.com/downloads/connector/j/
- Click the Archives tab.
-
Click the Product Version drop-down menu and select 5.1.46.
The Operating System drop-down menu automatically selects Platform Independent for you.
- Download the ZIP archive (for Windows) or TAR archive (for Linux and macOS).
- Unpack the archive file using WinZIP (for Windows) or another utility.
-
Locate the following JDBC driver inside the archive:
mysql-connector-java.5.1.46.jar
- Install the driver on your Windows, macOS or Linux system.
Download the driver for MySQL 8.0
-
Navigate to the MySQL Community Downloads website. located at:
https://dev.mysql.com/downloads/connector/j/
-
In the General Availability (GA) Release tab, click the drop-down menu and select the operating system as Platform Independent.
WHD supports the MySQL 8.2.0.
- Click Go to Download Page.
-
Download the ZIP archive (for Windows) or TAR acrhive (for Linux or macOS).
- Unpack the archive file using WinZIP (for Windows) or another utility.
-
Locate the JDBC driver inside the archive.
- Install the driver on your Windows or Linux or macOS system.
Install the driver
Install the driver on your Windows, macOS or Linux system.
Install the driver on a Windows system
- Log in to the server hosting Web Help Desk.
-
Navigate to the targeted directory.
If you are running Web Help Desk 12.6 and below, navigate to:
<webhelpdesk>\bin\jre\lib\ext
If you are running Web Help Desk 12.7 and later, navigate to:
<webhelpdesk>\bin\webapps\helpdesk\WEB-INF\lib
- Copy the JDBC driver file into the
lib
directory. -
Restart Web Help Desk.
The MySQL JDBC driver is installed on your system.
Install the driver on a macOS system
- Log in to the server hosting Web Help Desk.
-
Navigate to the targeted directory.
If you are running Web Help Desk 12.6 and below, navigate to:
<webhelpdesk>/bin/jre/lib/ext
If you are running Web Help Desk 12.7 and later, navigate to:
<webhelpdesk>/bin/webapps/helpdesk/WEB-INF/lib
- Copy the JDBC driver into
lib
directory. -
Restart Web Help Desk.
The MySQL JDBC driver is installed on your system.
Install the driver on a Linux system
- Log in to the server hosting Web Help Desk.
-
Navigate to the targeted directory.
If you are running Web Help Desk 12.6 and below, navigate to:
<webhelpdesk>/bin/jre/lib/ext
If you are running Web Help Desk 12.7 and later, navigate to:
<webhelpdesk>/bin/webapps/helpdesk/WEB-INF/lib
- Copy the JDBC driver into the
lib
directory. -
Restart Web Help Desk.
The MySQL JDBC driver is installed on your system.
MySQL
Последнее обновление: 08.08.2018
Одной из наиболее популярных СУБД в связке с Java является MySQL. Поэтому рассмотрим, как мы можем работать с MySQL в Java.
Подробнее про работу с MySQL можно посмотреть в соответствующем материале Руководство по MySQL
Для работы с MySql в Java необходимо установить официальный драйвер MySQL Connector/J. Загрузим его с адресса
https://dev.mysql.com/downloads/connector/j/. Распакуем загруженный архив,
найдем там собственно драйвер, который представляет собой файл с расширением jar (на момент написания данной статьи это файл
mysql-connector-java-8.0.11.jar), и положим его в папку программы.
Убедимся, что мы в прицнипе можем осуществлять взаимодействие с MySQL через данный драйвер. Для этого определим следующий код программы:
public class Program{ public static void main(String[] args) { //java -classpath c:\Java\mysql-connector-java-8.0.11.jar;c:\Java Program try{ Class.forName("com.mysql.cj.jdbc.Driver").getDeclaredConstructor().newInstance(); System.out.println("Connection succesfull!"); } catch(Exception ex){ System.out.println("Connection failed..."); System.out.println(ex); } } }
Для загрузки драйвера здесь применяется строка
Class.forName("com.mysql.cj.jdbc.Driver").getDeclaredConstructor().newInstance();
Метод Class.forName() в качестве параметра принимает строку, которая представляет полный путь к классу драйвера с учетом
всех пакетов. В случае MySQL это путь «com.mysql.cj.jdbc.Driver». Таким образом, Метод Class.forName загружает класс драйвера, который будет использоваться.
Далее вызывается метод getDeclaredConstructor(), который возвращает конструктор данного класса. И в конце вызывается метод
newInstance(), который создает с помощью конструктора объект данного класса. И после этого мы сможем взаимодействовать с сервером MySQL.
Убедимся, что сервер MySQL запущен, и скомпилируем и запустим программу на выполнение:
C:\Java>javac Program.java C:\Java>java -classpath c:\Java\mysql-connector-java-8.0.11.jar;c:\Java Program Connection succesfull! C:\Java>
В моем случае класс программы и драйвер размещены в папке C:\Java. Поэтому при выполнении программы после параметра -classpath
я указываю полный путь к файлу драйвера — «c:\Java\mysql-connector-java-8.0.11.jar». Далее после точки с запятой указывается каталог, где находятся
файлы программы, то есть опть же это каталог «C:\Java». И после этого идет название выполняемого класса программы — «Program».
И если все сделано правильно, то при выполнении программы мы можем увидеть на консоли строку «Connection succesfull!». После этого мы можем начать
взаимодействовать с MySQL.
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 9.3 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.
Security
Oracle values the independent security research community and believes that responsible disclosure of security vulnerabilities helps us ensure the security and privacy of all our users. Please refer to the security guidelines document for additional information.
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.
- OpenTelemetry API and SDK are required for enabling OpenTelemetry native instrumentation.
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>9.3.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>9.3.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
We greatly appreciate feedback from our users, including bug reports and code contributions. Your input helps us improve, and we thank you for any issues you report or code you contribute. Please refer to the contributing guidelines document 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 X.
- MySQL Blog.
- MySQL Connectors Blog archive.
- MySQL Newsletter.
- MySQL Bugs Tracking System.
For more information about this and other MySQL products, please visit MySQL Contact & Questions.