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.xxx:3306/myapp
to db.url=jdbc:mysql://127.0.0.1:3306/myapp
, db.url=jdbc:mysql://localhost:3306/myapp
, jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/${OPENSHIFT_APP_NAME}
but I still got error and my webapp doesn't work.
Update:
mysql> select user, host from mysql.user;
+--------------+-------------+
| user | host |
+--------------+-------------+
| admink5J5aXX | % |
| admink5J5aXX | 127.x.x.x |
+--------------+-------------+
Is there anyone can address the root cause of this error? Please help! :(
Thanks in advance.
P/s: My English is not good
There is a connection config error in this case; username is used as a password:
<property name="password" value="${db.username}" />
...should read:
<property name="password" value="${db.password}" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.