问题
I am preparing to use jdbc for the first time and am in the process of installing the jdbc driver for MySQL.
However, it is unclear to me which of these files to move to the WEB_INF/lib folder in Eclipse. They both seem to contain the same content and are included together in the downloaded zip file for the MySQL connector.
I have searched everywhere but have been unable to find any documentation to explain which of these files to use.
回答1:
I thought you were joking, but I just downloaded the zip from https://dev.mysql.com/downloads/connector/j/ and, indeed, it contains both.
The mysql-connector-java-5.1.46.jar
and mysql-connector-java-5.1.46-bin.jar
are binary identical, except for the META-INF/INDEX.LIST
(which contains the actual jar filename). I have unzipped both and compared them using kdiff3.
In short: you can use either: whatever you prefer.
This change is mentioned in CHANGES
as:
- Fix for Bug#27231383, PROVIDE MAVEN-FRIENDLY COMMERCIAL PACKAGES WITHOUT "-BIN".
Interestingly, there is no bug 27231383 in the MySQL bug tracker (the number is too high for the 'normal' bugs listed), so maybe it is from another system within Oracle.
In addition, the online Connector/J 5.1.46 release notes mentions:
The bundle for Connector/J 5.1 delivered by Oracle now contains an additional jar package with the name
mysql-connector-java-5.1.ver.jar
(mysql-connector-java-commercial-5.1.ver.jar
for commercial bundles). It is identical with the other jar package with the original package namedmysql-connector-java-5.1.ver-bin.jar
(mysql-connector-java-commercial-5.1.ver-bin.jar
for commercial bundles), except for its more Maven-friendly file name. (Bug #27231383)
Presumably, given the closer match to Maven naming conventions, this makes it easier to install the library in local/company Maven repositories (eg if you don't want, or legally can't, use Maven Central).
But to repeat: they are the same, and you can use either one.
来源:https://stackoverflow.com/questions/49387428/which-mysql-connector-do-i-use-mysql-connector-java-5-1-46-jar-or-mysql-connect