mercredi 2 décembre 2015

Java Webapp could not connect mysql on openshift

I'm new openshift. I created Tomcat 7 (JBoss EWS 2.0) application on openshift to host my webapp. Now I'm deploying my war file and I'm facing with an error.

My web app could not connect to mysql. Error as below:

java.sql.SQLException: Access denied for user 'admink5J5aXX'@'127.x.x.x' (using password: YES)

And here is my config for connection:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="${db.url}" />
    <property name="username" value="${db.username}" />
    <property name="password" value="${db.username}" />
</bean>

And there properties is:

db.username=admink5J5aXX
db.password=password
db.url=jdbc:mysql://127.x.x.x:3306/myapp

User, password and host were provided by OpenShift.

env | grep MYSQL
OPENSHIFT_MYSQL_DB_PORT=3306
OPENSHIFT_MYSQL_DB_HOST=127.x.x.x
OPENSHIFT_MYSQL_DB_PASSWORD=password
OPENSHIFT_MYSQL_IDENT=redhat:mysql:5.5:0.2.20
OPENSHIFT_MYSQL_DB_USERNAME=admink5J5aXX
OPENSHIFT_MYSQL_DB_URL=mysql://admink5J5aXX:password@127.x.x.x:3306/
OPENSHIFT_MYSQL_VERSION=5.5

I try to change db.url=jdbc:mysql://127.x.x.x:3306/myapp to db.url=jdbc:mysql://127.0.0.1:3306/myapp, db.url=jdbc:mysql://localhost:3306/myapp but I still got error and my webapp doesn't work.

Are there anyonce can address the root cause of this error? Please help! :(

Thanks in advance.

P/s: My English is not well




Aucun commentaire:

Enregistrer un commentaire