I'm on OSX Mavericks, running Intellij 12, trying to add a datasource already defined in XML, using the persistence facet.
I can find and select the source fine, but when I try to test the connection I get:
Connection to XXXXX failed: Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:190) at com.intellij.persistence.database.console.RemoteJdbcServer.main(RemoteJdbcServer.java:15)
Looks like it's just a classpath problem, but I'm having a surprisingly rough time figuring out what I have to do to get the mysql jar on the classpath.
Every question I've found deals with adding the jar to the classpath of your compiled or testing application, that's NOT what I'm looking for here. My application connects to mysql fine, it's the IntellijIDE that's having problems. Where do I need to add the path to this file?
For Intellij 15 (maybe lower versions) this works:
Add the JDBC library using Intellij:
In IntelliJ goto View -> Tool Windows -> Database
Inside Click + button -> DataSource -> MySql
as shown below
In below screen enter your mysql connection details and click Test Connection...
make sure you download mysql driver for connection
Either of the following options should work
add jar to the global libraries of the project.
put jar in the lib directory of intellij.
put jar in the ext lib of the jre that intellij is running under.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With