Use the ODBC-JDBC Gateway to connect Microsoft SQL Server to MySQL and:
MySQL provide several connectors to enable client applications to access MySQL databases. One such connector is the MySQL Connector/J, which is a piece of database middleware known as a JDBC driver. A JDBC driver allows a Java application to access external data. MySQL's JDBC driver allows Java applications to access data stored in MySQL.
SQL Server is not written in Java however and does not provide a way for a linked server to access a database by using JDBC. SQL Server can use an ODBC driver, a different piece of database middleware, to access external data. The ODBC-JDBC Gateway connects an application that uses ODBC to a database that uses JDBC. To the application, the ODBC-JDBC Gateway is an ODBC driver. To the JDBC driver the ODBC-JDBC Gateway is a Java application.
Note If you intend using SSIS, please contact the Easysoft support team () for pre-release version of the ODBC-JDBC Gateway. You need version 2.4.9 or later, which is not currently available from the Easysoft web site.
For installation instructions, see the ODBC-JDBC Gateway documentation.
Before you can use the ODBC-JDBC Gateway to connect your ODBC application to MySQL, you need to configure a System ODBC data source. An ODBC data source stores the connection details for the target database.
To run ODBC Administrator on 32-bit Windows, open Administrative Tools in Control Panel, and then open Data Sources (ODBC). (On older versions of Windows, the Control Panel applet that launches ODBC Administrator is labelled Data Sources.)
There are two versions of ODBC Administrator on this platform. The version of ODBC Administrator that you need to run depends on whether you have a 32-bit or a 64-bit version of SQL Server. To find out which version of SQL Server you have, connect to your SQL Server instance, and then run this SQL statement:
If you have the 64-bit version of SQL Server and want to use a linked server with MySQL, you need to run 64-bit version of ODBC Administrator. To do this, open Administrative Tools in Control Panel, and then open Data Sources (ODBC). (On Windows Server 2003 and earlier, the Control Panel applet that launches ODBC Administrator is labelled Data Sources. On Windows 8 and later, the Control Panel applet is labelled ODBC Data Sources (64-bit).)
If you have the 32-bit version of SQL Server or want to use SSIS with MySQL, you need to run the 32-bit version of ODBC Administrator. To do this, in the Windows Run dialog box, type:
If you are not sure whether your version of Windows is 32-bit or 64-bit, follow the instructions in this Microsoft Knowledge Base article to find out.
Use ODBC Administrator to create your ODBC-JDBC Gateway data source.
|Class Path||<path>\mysql-connector-java-version-bin.jar |
C:\Program Files (x86)\MySQL\MySQL Connector J\mysql-connector-java-5.1.35-bin.jar
You can now use the ODBC-JDBC Gateway Data Source to connect SQL Server to MySQL.
You need to log on with an account that is a member of the SQL Server sysadmin fixed server role to create a linked server.
The other provider options should be unchecked.
MYSQL_DSNif you are following the example), and then choose OK.
SQL Server verifies the linked server by testing the connection.
A four part table name has the format:
For MySQL you need to omit the database name and schema. For example:
SELECT * from MYSQL_JDBC...sales_by_film_category
SELECT * FROM OPENQUERY(MYSQL, 'SELECT * FROM sales_by_film_category')
SQL Server sends pass-through queries as uninterpreted query strings to the ODBC-JDBC Gateway. This means that SQL Server does not apply any kind of logic to the query or try to estimate what that query will do.
Note The MySQL
TEXT data type is incompatible with SQL Server. If you attempt to retrieve a
TEXT column, you will get error such as "Requested conversion is not supported." or "Restricted data type attribute violation". To use a
TEXT data in SQL Server, you need to convert the data in MySQL to a type that SQL Server does support. For example:
SELECT * FROM OPENQUERY(MYSQL, 'SELECT CAST(description AS char(255)) AS description from film where film_id = 1000')
These instructions assume that you have Microsoft Visual Studio and SQL Server Data Tools for Visual Studio installed.
film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update 1001,"Mad Max: Fury Road","Haunted by his turbulent past, Mad Max believes the best way to survive is to wander alone",2015,1,1,3,"4.99",50,"18.99","NC-17","Trailers,Commentaries,Behind the Scenes","2015-05-08 00:00:01" 1002,"Avengers: Age of Ultron","When Tony Stark tries to jumpstart a dormant peacekeeping program, things go awry",2015,1,1,3,"4.99",50,"18.99","NC-17","Trailers,Commentaries,Behind the Scenes","2015-05-08 00:00:01"
Flat File Source is under the Other Sources list.
database timestamp [DT_DBTIMESTAMP]. Choose OK.
Ignore failure. Choose OK.
ODBC Destination is in the Other Destinations list.
film. Choose Mappings and then choose OK.
Note If you choose the combo box down arrow to retrieve the list of tables, you will get garbled text instead of table name qualifiers. You need to remove the qualifiers and . characters from the table name. For example, replace
mytable. A version of the ODBC-JDBC Gateway that enables you to use the automatically populated table names is available from the Easysoft support team (). You need version 2.4.9 or later.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.