2

Lots of answers to this question already but none of them are working for me. I feel like I've tried everything. Anyone else have any ideas?

code:

private DataSource ds1;
private Connection dc1 = null;

Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env");
ds1 = (DataSource)envContext.lookup("jdbc/CMS1-DEV");

dc1 = ds1.getConnection();

WEB-INF/web.xml:

<resource-ref>
    <description>CMS Data</description>
    <res-ref-name>jdbc/CMS1-DEV</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>        

META-INF/context.xml

<context>
    <resource 
        name="jdbc/CMS1-DEV"
        auth="Container" 
        type="jaxax.sql.DataSource" 
        username="******" 
        password="******" 
        driverClassName="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://localhost:3306/bitnami_wordpress"
        maxActive="10" maxIdle="4"/>

I have the mysql-connector-java-5.1.17.jar in the META-INF/lib directory

stack trace:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at us.deans.parrot.ParrotController.doPost(ParrotController.java:77)
wintermute
  • 121
  • 3
  • 9
  • There is a typo here `type="jaxax.sql.DataSource"` should be `type="javax.sql.DataSource" ` – SMA Feb 14 '15 at 17:46
  • LOL - I spent an entire day beating my head on the desk over this. Tried everything. I guess there's something to be said for a second set of eyes. Thank you so much almas - that was indeed the problem. – wintermute Feb 14 '15 at 18:35
  • Do you mind if i answer it in answer section so it would help others? – SMA Feb 14 '15 at 18:38
  • you cab try with: url="jdbc:mysql://127.0.0.1:3306/bitnami_wordpress" – DevOps85 Feb 15 '15 at 16:38

1 Answers1

2

There is a typo here in your configuration - "jaxa" instead of "java".

Change following from:

type="jaxax.sql.DataSource" 

To

type="javax.sql.DataSource"
mskfisher
  • 3,291
  • 4
  • 35
  • 48
SMA
  • 36,381
  • 8
  • 49
  • 73