Accessing Remote MySQL Server from Windows 7 [message #1731646] |
Sun, 08 May 2016 19:20 |
Arthur Chan 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03623 seconds