So i followed all the steps listed in other posts to add mysql-connector-java-5.1.36-bin to my class path in intellij 12 and when i'm writing code intellij clearly sees it and lets me import it, but when I run the application inside of tomcat I get a ClassNotFoundException
Below are screen shots of my set ups and my code.
public void runLookUp(String s){
String url = "jdbc:mysql://localhost:3316/test";
String username = "java";
String password = "password";
System.out.println("Connecting database...");
System.out.println("Loading driver...");
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded!");
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Cannot find the driver in the classpath!", e);
}
try {
Connection connection = (Connection) DriverManager.getConnection(url, username, password);
System.out.println("Database connected!");
} catch (SQLException e) {
throw new IllegalStateException("Cannot connect the database!", e);
}
}
I am aware that doing it in global libraries instead of my lib directory is bad form I did it originally there and moved it to global as an attempted fix to this issue and just haven't moved it back yet. Given that this seems to work for everyone else I assume its something in the way I have my tomcat deploying from intellij, any thoughts?