So I'm stuck with a small problem in a rather large application atm, to which - after x1000 tries, I'm at a loss.
I'm trying to connect to mysql database within a DAO pattern, viewed by a JSF page.
First of all the getConnection part of daoManager:
Connection con = null;
DataSource ds;
public Connection getConnection() throws Exception {
try {
Class.forName("com.mysql.jdbc.Driver");
InitialContext cxt = new InitialContext();
ds = (DataSource) cxt.lookup( "java:/comp/env/jdbc/db");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
return ds.getConnection();
}
Now, this should already here be working given the correct driver placement. I've tried a few things, placing the driver in both the project and in WEB-INF, ofcourse marked as a library:
Further more I've also included said driver in tomcat/lib.
The context.xml is as follows:
<Resource name="jdbc/db" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="******" password="******" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/javatest"/>
And lastly the web.xml is as follows:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/db</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Now.. The error in the stacktrace is as follows:
java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
Caused by: java.sql.SQLException: No suitable driver
If any more info is needed, don't be hesitant to holla at me :)