Search code examples
mysqltomcatmeta-inf

context.xml in Tomcat without DB password


I have a servlet application running on Tomcat 7 and wish to connect to MySQL locally.

My local MySQL user does not have a password, and I wish to keep it that way for convenience.

However, if I do not use the password attribute under Resource in context.xml, it tries to connect to the DB without the username even though I have set it.

How can I connect without a password?

Below is my context.xml file, if it matters.

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource
        name="jdbc/mysql"
        auth="Container"
        type="javax.sql.DataSource"
        maxActive="100"
        maxIdle="30"
        maxWait="10000"
        username="whirlwin"
        password="removeMe"
        driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/theDB?autoReconnect=true"/>
</Context>

Solution

  • Have you tried leaving empty string for the password?

    If this doesn't help, post what you get running mysql -uwhirlwin -hlocalhost from the command line.