nyanev
nyanev

Reputation: 11519

Tomcat 7 with MySql

I use Mac OSx 10.6 and want to use Tomcat 7 server with MySql db. My context.xml file:

<?xml version='1.0' encoding='utf-8'?>
<Context>

    <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
           factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
           maxActive="100" maxIdle="30" maxWait="10000"
           username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://localhost:3306/javatest"/>
</Context>

And my deployment descriptor:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID" version="2.4">
    <display-name>Love Finder</display-name>
     <servlet>
    <servlet-name>customer</servlet-name>
    <servlet-class>com.neya.love.finder.pl.CustomerServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>customer</servlet-name>
    <url-pattern>/customer.do</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/TestDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

I have table javatest but when make connection to db I have this Exception:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (null,  message from server: "Host '192.168.0.100' is not allowed to connect to this MySQL server")

Can someone help me?

Upvotes: 1

Views: 3169

Answers (3)

Jaydee
Jaydee

Reputation: 4158

Can you connect using the MySQL Client on the computer?

In a shell type

mysql -ujavauser -p

If not then duffymo is probably correct.

Upvotes: 1

duffymo
duffymo

Reputation: 309008

You will want to GRANT permissions to that server. MySQL requires username, password, and client IP.

http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Upvotes: 2

Lolo
Lolo

Reputation: 4367

You might want to check if your MySQL configuration file (my.ini) has the following entry:

 #Don't allow connections via TCP/IP.
 skip-networking

Upvotes: 1

Related Questions