Skip to main content
2 de 4
added 67 characters in body
Geison Santos
  • 4,6mil
  • 11
  • 48
  • 73

Como mencionado pelo usuário user6053 a configuração necessária para usar o MySQL no CloudBees consiste na configuração de três arquivos basicamente:

cloudbees-web.xml (o arquivo deve ser criado na pasta WEB-INF)

<?xml version="1.0" encoding="UTF-8"?>
<cloudbees-web-app xmlns="http://www.cloudbees.com/xml/webapp/1">
 <!-- Application ID (formatted CB_ACCOUNT/APPNAME) -->
 <appid>geisonsn/webbusam</appid><!-- ID da minha aplicação no CloudBees-->

 <!-- DataSources (use names refererenced via <resource-ref> in WEB-INF/web.xml) -->
    <resource name="jdbc/webbusam" auth="Container" type="javax.sql.DataSource">
        <param name="username" value="USUARIO" />
        <param name="password" value="SENHA" />
        <param name="url" value="jdbc:mysql://us-cdbr-cb-east-01.cleardb.net:3306/cb_dbbusam" />

        <!-- Connection Pool settings -->
        <param name="maxActive" value="20" />
        <param name="maxIdle" value="2" />
        <param name="maxWait" value="10000" />
        <param name="validationQuery" value="SELECT 1" />
    </resource>
</cloudbees-web-app>

web.xml

    <resource-ref>
        <res-ref-name>jdbc/webbusam</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
 xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 <persistence-unit name="primary">
    <non-jta-data-source>java:comp/env/jdbc/webbusam</non-jta-data-source>
    <properties>
       <property name="hibernate.hbm2ddl.auto" value="update" />
       <property name="hibernate.show_sql" value="false" />
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    </properties>
 </persistence-unit>
</persistence>

Importante: A aplicação do exemplo usa o servidor JBoss7.

Referências

  1. http://stackoverflow.com/questions/12693090/how-to-configure-a-mysql-datasource-in-a-cloudbees-java-ee6-application
  2. http://wiki.cloudbees.com/bin/view/RUN/CloudBeesWebXml
Geison Santos
  • 4,6mil
  • 11
  • 48
  • 73