I was getting this error after clicking the test connection button for a MongoDB connection in the IntelliJ IDEA Database tab:
Driver class 'com.dbschema.MongoJdbcDriver' is incompatible with current JRE.
It took me over an hour to fix this because there were literally no results when I googled for the exact search term.
There are multiple ways to fix this error, which I'll post below.
1 Answer 1
For some reason, my IntelliJ IDEA (the IDE itself, not my code) was bootstrapped from JDK 17. Using a newer version fixed the error. Here's how I did that:
Go to Help -> Find Action
Type "Choose Boot Java Runtime for the IDE"
Select a newer Java version. I chose Java 21:
IntelliJ will ask you to restart. Click Okay.
The
Driver class 'com.dbschema.MongoJdbcDriver' is incompatible with current JREerror went away and I was able to successfully connect.
Obviously that warning in step 3 is pretty suspicious. It doesn't bother me because I'm just trying to get past this, and I'll be setting up a new computer in a few days.
Alternatively, you could use a different MongoDB driver than the one that comes with IntelliJ IDEA, but I tried and ran into different connection problems with that.
I could have tried using an older version of the IntelliJ IDEA MongoDB driver until it was compatible with the IntelliJ IDEA runtime, but I didn't go down that route myself. I can't guarantee it'll solve the problem.