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)
4
  • There is a typo here type="jaxax.sql.DataSource" should be type="javax.sql.DataSource" Commented Feb 14, 2015 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. Commented Feb 14, 2015 at 18:35
  • Do you mind if i answer it in answer section so it would help others? Commented Feb 14, 2015 at 18:38
  • you cab try with: url="jdbc:mysql://127.0.0.1:3306/bitnami_wordpress" Commented Feb 15, 2015 at 16:38

1 Answer 1

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.