Connect to Remote MySQL Host from Windows 7
Posted by: Arthur Chan
Date: May 08, 2016 01:31PM


I am trying to access a MySQL database on a remote Ubuntu host from my local laptop running Eclipse on Windows 7.

I have loaded mysql-connector-java-5.1.38-bin.jar from Oracle-MySQL

My little Java test to load driver failed with following error message:
Error: Cannot find MySQL JDBC Driver!

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at aboutMySQL.LoadDriver.main(

I am using Widnows 7 and this is my CLASSPATH:
%JAVA_HOME%/bin;%JAVA_HOME%\lib; %JAVA_HOME%\jre\lib; %JAVA_HOME%\jre\lib\ext; %JAVA_HOME%\jre\lib\ext;C:\Program Files\Mysql\lib\mysql-connector-java-5.1.38-bin.jar\

This is my little Java load driver test:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

// WARNING: do not import com.mysql.jdbc.*
// You must have already installed Connection/J from here:
// ...    then login and download the correct version. We have downloaded 5.1

public class LoadDriver {

	public static void main(String[] args) {
		try {
		} catch (ClassNotFoundException ex) {
			System.out.println("Error: Cannot find MySQL JDBC Driver!\n");

		System.out.println("MySQL JDBC Driver registered\n");
		Connection conn = null;
		try {
			conn = DriverManager.getConnection("jdbc:mysql://<ip address:port>/databasename" + "username=scott + password=tiger);
		} catch (SQLException ex) {
			System.out.println("Connection to mysql failed, check output console!\n");

		if (conn != null) {
			System.out.println("You made it, you can take control of your database now\n");

		} else {
			System.out.println("Failed to connect to mysql!\n");

Options: ReplyQuote

Written By
Connect to Remote MySQL Host from Windows 7
May 08, 2016 01:31PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.