Today learn how to use Java to manipulate the database, tutorial video There are two methods, one is JDBC-ODBC Bridge connection, one is the direct use of JDBC. I chose the latter.
But not as simple as the tutorial, the tutorial uses SQL Server 2000, I use MySQL, and then I am a small white one, in Baidu to find information to get their own.
First downloaded a JDBC driver, I downloaded the Mysql-connector-java-5.1.35-bin.jar, and then began to use in MyEclipse, the code is as follows: The code is not error, but when I run, it will appear this error
I am looking for information online, which may be caused by the following 4 reasons:
One: There was a problem with the connection URL format (Connection conn=drivermanager.getconnection ("Jdbc:mysql://localhost:3306/xx", "root", "XXXX")
Two: Error driving string (com.mysql.jdbc.Driver)
Three: The classpath does not include the appropriate MYSQL_JDBC driver (driver to be consistent with your database version)
Four: The drive jar package is placed in the wrong place.
I checked it out, one or two points right, and then I reconfigured the 3rd. For the fourth item, I put the jar bag inside the jdk/jre/lib/ext. However, this error is still displayed.
The MySQL I use is version 5.1.73, with the JDBC driver 5.1.35, I can't find the exact same version of MySQL as JDBC.
I suspect that the possible causes are:
The 1.JDBC differs from the MySQL version.
2. I have also installed 5.6 versions of MySQL before, and I am not sure whether these two different versions of the database will cause this problem.
Hope to have predecessors can point out, thank you.
Java connection to MySQL problem