You should change the declaration of the method:
public void connect() throws ClassNotFoundException
But I don't understand why the line Class.forName(driver); is there,
because you don't assign the return value to a variable. If you remove
the line, you don't need to change the declaration of the method and the
code will do the same.