I have successfully installed My SQL on my machine and have been given the following code to load the driver's which works to a certain extent:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class LoadDriver
{
public static void main (
String [] args)
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("Driver Loaded");
}
catch (Exception ex)
{
System.out.println("Failure");
}
try
{
Connection conn = DriverManager.getConnection
("jdbc:mysql://localhost/menagerie");
System.out.println("Connection = " + conn);
}
catch (SQLException ex)
{
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}
}
The
java is compiled in a file on my desktop but when I run it, whilst running MySQL, its output is:
Driver Loaded
SQLException: Access denied for user ''@'localhost(using password:no)
SQLState:28000
VendorError: 1045.
I can get into SQL ok by using a password but
JDBC is another matter.I realise this is more of a MYsql issue but the MySQL forum is not at all helpful on tis issue despite it being an apparently frequent problem.
Any hints appreciated, apologies if it's something obvious I've missed!