Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Accessing Remote MySQL Server from Windows 7
Accessing Remote MySQL Server from Windows 7 [message #1731646] Sun, 08 May 2016 19:20 Go to next message
Arthur Chan is currently offline Arthur ChanFriend
Messages: 44
Registered: September 2015
Member
Hi.

I am trying to access a MySQL database on a remote Ubuntu host from my local laptop running Mars 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 java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at aboutMySQL.LoadDriver.main(LoadDriver.java:15)




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\
(Note: I am trying out a few variations of CLASSPATH... same error)
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: www.mysql.com/downloads
// ...    then login and download the correct version. We have downloaded 5.1

public class LoadDriver {

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

		System.out.println("MySQL JDBC Driver registered\n");
		Connection conn = null;
...
}

[Updated on: Sun, 08 May 2016 21:27]

Report message to a moderator

Re: Accessing Remote MySQL Server from Windows 7 [message #1731647 is a reply to message #1731646] Sun, 08 May 2016 21:40 Go to previous message
Arthur Chan is currently offline Arthur ChanFriend
Messages: 44
Registered: September 2015
Member
RESOLVED
(1) Right-click on project, in my case LoadDriver";
(2) Select "Build Path"
(3) Select COnfigure Build Path
(4) Click on the Library tab
(5) Click on Add External JARs...

Navigate to the directory, in my case C:\Program Files\Mysql\bin
The select the .jar file

My LoadDriver works after that.

You are welcome to use the LoadDriver, it's nice-to-have for testing connections
Previous Topic:Eclipse wizard hanging
Next Topic:InformationControl setting return to default when focous on Text hover in java
Goto Forum:
  


Current Time: Sat Oct 12 09:52:29 GMT 2024

Powered by FUDForum. Page generated in 0.03623 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top