Reputation: 3028
Have a test servlet that connects to Mariadb jdbc connection.
It's not finding the jar file that's in the WEB-INF/lib folder - the jdbc driver.
If I save the jar file in catalina's lib folder, I get the same error message the first time - but it works after that on servlet reload
The error I get is:
java.sql.SQLException: No suitable driver found for jdbc:mariadb://localhost:3306/test
Any help?
Here's my simple servlet
Connection connection = null;
String url = "jdbc:mariadb://localhost:3306/test";
String user = "root";
String pwd = "password";
String msg = "FAILED!";
try {
connection = DriverManager.getConnection(url, user, pwd);
msg = "CONNECTED!";
} catch (SQLException e) {
e.printStackTrace();
}
The error message no-suitable-driver - is from the printStackTrace()
Upvotes: 0
Views: 34
Reputation: 3028
Need to load the class explicitly
try
{
Class.forName("org.mariadb.jdbc.Driver");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
Upvotes: 0