I know this is a common question, but despite adding
You will also need to add the library as a dependency to the module that needs it.
Project Settings > Modules. Select the Module that needs the library (in your case it seems like you have only one module in your project,
ChatBot). Select the
Dependencies tab. Click the '+' button and choose
Library...). Finally, select the
mysql-connector.. library that you added to the project.
Edit: I see now that this wasn't your problem at all. The problem with your code is that you have an unhandled exception from
Class.forName(). The method can throw the checked exception:
ClassNotFoundException, which must be handled by adding a
catch or by adding
throws ClassNotFoundException to the method signature of
In such cases with error in the code, the easiest way to figure out what's wrong to simply move the caret to the code with the red squigly line and see what IDEA says in the bottom status bar. Alternatively you can hover the mouse pointer above it and the error message is presented as a popup.