Hello all, I am having problems setting up a connection with a mysql database that i'm going to need to use for one of my projects. My code to establish the connection is as follows:

import java.sql.*;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.ResultSet;
import javax.sql.ConnectionEvent;
import java.sql.DriverManager;

public class SQL {

static String DRIVER = "com.mysql.jdbc.Driver";
static String DATABASE_URL = "jdbc:mysql:://mysql.ee.port.ac.uk:3306/ece00249";
static String UNAME = "ece00249";
static String PW = ".......";
static Connection conn = null;
static String database = "ece00249";
Statement statement = null;
ResultSet Rs = null;
public static void main(String[] args){
conn = DriverManager.getConnection(DATABASE_URL, UNAME, PW);
throw new SQLException ("database not reached");
catch(ClassNotFoundException e){
catch(Exception e){

I am getting the following error:

C:\java\database>java SQL
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I have got the mysql-connector-java-5.1.19-bin.jar file in several locations, Where SQL.java is, inside my \bin directories linking to my classpath.

What am i doing wrong?

You need to use a classpath with the jar file containing the missing class.
java -cp .;mysql-connector-java-5.1.19-bin.jar SQL

Edited 4 Years Ago by NormR1

This question has already been answered. Start a new discussion instead.