My Liferay portal 7 ga4 is running on wildfly 10. I've created a Liferay MVC portlet and deployed. I'm trying to connect to MySql database but getting this error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I imported mysql-connector-java-5.1.42-bin.jar by (Right Click on project>Build Path>Configure Build Path>Add JARs. It went under "Referenced Libraries".
And here's the code of view.jsp
try{
String connectionURL = "jdbc:mysql://localhost/employees";
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "");
statement = connection.createStatement();
if(!connection.isClosed()){
out.println("Successfully connected to MySQL server" + "<br/>");
}
} catch(Exception ex){
out.println("Unable to connect to database: "+ ex);
}
Can someone please help me? I'm totally new to Liferay and Java.
Thank you.