I am 97% sure that I have set my java web application correctly but I still get an error which points to missing the Mariadb connector or something that is close to that. I have tried to fix it but to no avail... I have
pom.xml
file (shown in first image).jar
file is there. (shown in first image) Upon checking the GlashFish Server tab on run, I can read this :
java.lang.ClassNotFoundException : com.mariadb.jdbc.Driver
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1580)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1430)
... and at least 20 more locations.
Here I am trying to print the result in console to see if my application managed to connect to the remote database server, but I get nothing since it seems to crash before at the line Class.forName("com.mariadb.jdbc.Driver");
which I have found to be the right syntax for mariadb jdbc on their website . To save you time, they are saying that this is the legacy way of doing this, but that it still works. I did try to remove all the parameters from the url connection to only the user and password in getConnection();
line, but it still fails. Am I missing something?
To avoid confusion in the screenshot, myddns.link is including :3306 so that is not the error.
Should be
Class.forName("org.mariadb.jdbc.Driver");
instead of
Class.forName("com.mariadb.jdbc.Driver");
The documentation you linked even states it explicitly:
Please note that the driver class provided by MariaDB Connector/J is not com.mysql.jdbc.Driver but org.mariadb.jdbc.Driver!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.