Issue
I'm using the mariadb-java-client-1.5.7.jar
connector for MariaDB, and it does not work.
Here's the connection code:
public DataAccess() throws SQLException, ClassNotFoundException {
this.driver = "org.mariadb.jdbc.Driver";
this.host = "jdbc:mariadb://localhost/bluebank";
this.user = "root";
this.password = "";
Class.forName(this.driver);
this.conn = DriverManager.getConnection(this.host, this.user, this.password);
}
I get:
java.sql.SQLException: No suitable driver found for jdbc:mariadb://localhost/bluebank
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at DAO.DataAccess.<init>(DataAccess.java:31)
Apart from adding as an external jar to the libraries, I've added it as a driver to the databases in (Services) in Netbeans. Also, if I remove the Class.forName()
, it doesn't work as well.
Solution
You forgot the port number of your database :
this.host = "jdbc:mariadb://localhost:port_number/bluebank";
Make sure that your db connector jar, exist in the your jar libraries: https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/
You can learn more here :
Connect to MariaDB from Java application in NetBeans on Linux (Mageia)
Hope this can help you
Answered By - YCF_L
Answer Checked By - Candace Johnson (JavaFixing Volunteer)