MySQL Connector/J Documentation :: 2.2.1 Setting the CLASSPATH (For Standalone Use)
HELP ME PLEASE!!
Im a newbie and have been trying to connect to mysql using jbuilder. Heres my code:
private static final String URL =
"jdbc:mysql://localhost";
private static final String USERID = "root";
private static final String PASSWORD = "password";
private Connection connection;
public databaseManager() throws SQLException
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch (Exception E)
{
System.err.println("Unable to load driver.");
E.printStackTrace();
}
System.out.println("Connecting to database...");
connection = DriverManager.getConnection(URL, USERID, PASSWORD);
System.out.println("...connection established.");
}
Im getting java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
So there is a problem with my connector.
I connected using the following info but found it really confusing and not worded very well.
http://dev.mysql.com/doc/connector/j/en/cj-setting-classpath.html
Im not sure if ive done this bit right. Please could someone tell me how to do this.
Also is the URL and username at the top ok, im not sure how this is formatted either.
Thanks in advance