Active6 years, 2 months ago
- MySQL Connectors MySQL provides standards-based drivers for JDBC, ODBC, and.Net enabling developers to build database applications in their language of choice. In addition, a native C library allows developers to embed MySQL directly into their applications.
- Xcode (with command line tools) is required for the MySQL Perl driver. Lines in bold are what you will have to type in at the Terminal. Replace with the name of your machine.
- MySQL Connector/J is the official JDBC driver for MySQL. MySQL Connector/J 8.0 is compatible with all MySQL versions starting with MySQL 5.5. Additionally, MySQL Connector/J 8.0 supports the new X DevAPI for development with MySQL Server 8.0.
- Devart ODBC Driver for Mysql provides high-performance and feature-rich connectivity solution for ODBC-based applications to access Mysql databases from Windows, Linux and Mac OS X, both 32-bit and 64-bit.
I wrote a program to connect to a database using jdbc with type 4 connectivity. The program compiles just fine but gives an exception of java.lang.ClassNotFoundException : com.mysql.jdbc.Driver. I have extracted all the folders in the folder in which my java file is and even placed all the jar files and database in the same folder. The database contains two records with ID 1 and 2. What could be the problem?
MySQL Type 4 Driver The JAR file for the MySQL driver is mysql-connector-java- version -bin-g.jar, for example, mysql-connector-java-5.0.5-bin-g.jar. Configure the connection pool using the following settings. MySQL Connector/J 5.1.29 - Java driver for converting JDBC calls to MySQL network protocol. Download the latest versions of the best Mac apps at safe and trusted MacUpdate Download, install, or update MySQL Connector/J for Mac from MacUpdate.
}
Archit VermaArchit Verma1,02022 gold badges1919 silver badges4040 bronze badges
3 Answers
If your
mysql-connector-java-5.0.8-bin.jar
file is located with a path like lib
within your Project like belowThen with a cmd prompt (assuming windows) change directory to this folder, then you would need to compile your class with
use
:
if not windows (only need quotes if spaces in file/folder names)then run with
Also make sure you dont have duplicate jars in use
Java DevilJava Devil8,57177 gold badges2626 silver badges4141 bronze badges
you need to have the jar containing
com.mysql.jdbc.Driver
in the class patheg
java -cp mysql.jar;. TestJDBC
where mysql.jar is the jar containing the class file
Mysql Mac Install
![Type 4 Driver For Mysql For Mac Type 4 Driver For Mysql For Mac](/uploads/1/2/6/0/126060472/654014354.gif)
com/mysql/jdbc/Driver.class
on a windows machine
placed
mysql-connector-java-5.0.8-bin.jar
and TestJDBC.class
in same folder.from the folder executed
java -cp mysql-connector-java-5.0.8-bin.jar;. TestJDBC
that worked as expected.
unix usually requires
java -cp mysql-connector-java-5.0.8-bin.jar:. TestJDBC
![Mysql drivers windows 10 Mysql drivers windows 10](/uploads/1/2/6/0/126060472/806785381.png)
6,60444 gold badges1818 silver badges3131 bronze badges
As answered by BevynQ, setting class path from command line sets the path(As best of my knowledge) for that particular current instance of cmd, if you exit/close and reopen command prompt, again you need to set the path.I guess two solutions for this to use jar files in your programs:
- Solution 1) Copy jar files in Program Files/Java/JRE/lib folder, so that it will be available for run time environment, But this is not recommended to add jar files in JDK/JRE.
- Solution 2) Set the classpath variable to place the full path of your jar file location, So that it will be available for run time environment:Copy full path of your jar file location, go to environment variable, search for user/system classpath variable(User variable for current login user, system variable for all users accounts on current windows) if it is there, edit it and put your path in starting, otherwise create a new classpath variable and place your full pathMake sure your IP address on the computer is 192.168.0.xxx (where xxx is between 2 and 254). D-link dir-601 driver for mac.
8,57177 gold badges2626 silver badges4141 bronze badges
Shailesh SaxenaMysql Driver 5.1
Shailesh SaxenaType 4 Driver For Mysql For Mac
2,90522 gold badges1414 silver badges2727 bronze badges