2015-09-11 3 views
0

Я пытаюсь подключиться к внешней базе данных mySql. я получаю сообщение об ошибке на консоли:OpenShift пытается подключиться к mySql

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'adminbnnSIES'@'localhost' (using password: YES))

Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection

Это как мой applicationContext.xml выглядит следующим образом:

<?xml version="1.0" encoding="UTF-8"?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> 
    <!-- Enable Spring Annotation Configuration --> 
    <context:annotation-config /> 
    <!-- Scan for all of Spring components such as Spring Service --> 
    <context:component-scan base-package="com.gwozdz.spring.service"></context:component-scan> 
    <!-- Create Data Source bean --> 
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
     destroy-method="close"> 
     <property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
     <property name="url" value="jdbc:mysql://127.X.XX.X:3306/test" /> 
     <property name="username" value="adminbnnSIES" /> 
     <property name="password" value="password" /> 
    </bean> 
    <!-- Define SessionFactory bean --> 
    <bean id="sessionFactory" 
     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
     <property name="dataSource" ref="dataSource" /> 
     <property name="mappingResources"> 
      <list> 
       <value>domain-classes.hbm.xml</value> 
      </list> 
     </property> 
     <property name="configLocation"> 
      <value>classpath:hibernate.cfg.xml</value> 
     </property> 
    </bean> 
    <!-- Transaction Manager --> 
    <bean id="transactionManager" 
     class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
     <property name="sessionFactory" ref="sessionFactory" /> 
    </bean> 
    <!-- Detect @Transactional Annotation --> 
    <tx:annotation-driven transaction-manager="transactionManager" /> 
</beans> 

Я не смог найти ответ на мой ответ в любом месте. В моей pom.xml я есть эта зависимость:

<dependency> 
    <groupId>mysql</groupId> 
    <artifactId>mysql-connector-java</artifactId> 
    <version>5.1.31</version> 
</dependency> 

О местном связи у меня нет такой проблемы, вот моя локальная установка боб:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
    destroy-method="close"> 
    <property name="driverClassName" value="com.mysql.jdbc.Driver" /> 
    <property name="url" value="jdbc:mysql://localhost:3306/test" /> 
    <property name="username" value="root" /> 
    <property name="password" value="" /> 
</bean> 

ответ

0

Я думаю, что проблема должна быть с хозяином вы указываете там, «localhost» не кажется правильным для внешней базы данных.

Это OpenShift руководство может быть полезно:

https://blog.openshift.com/cloud-connections-how-to-use-openshift-with-external-databases/

Код они используются в руководстве здесь:

https://github.com/codemiller/hellodb-java