简体   繁体   English

如何在Cloudbees Java EE6应用程序中配置Mysql数据源?

[英]How to configure a Mysql datasource in a Cloudbees Java EE6 application?

I'm trying to deploy an existing Jboss 7 war application on the Cloudbees Paas and I'm getting stuck with datasource configuration. 我试图在Cloudbees Paas上部署现有的Jboss 7 war应用程序,但是我陷入了数据源配置的困境。 Following this dedicated Cloudbees wiki entry and the related thread , I end up with the following error (already mentioned by others in the thread) during application startup : 在这个专用的Cloudbees Wiki条目相关线程之后 ,在应用程序启动期间,我遇到了以下错误(该线程中的其他人已经提到过):

javax.resource.ResourceException: Wrong driver class [class com.mysql.jdbc.Driver] for this connection URL [jdbc:cloudbees://cbdebate--1]

My configuration files are as follows: 我的配置文件如下:

cloudbees-web.xml cloudbees-web.xml

<?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>hck/debate</appid>

 <!-- DataSources (use names refererenced via <resource-ref> in WEB-INF/web.xml) -->
    <resource name="jdbc/debate" auth="Container" type="javax.sql.DataSource">
        <param name="username" value="myuser" />
        <param name="password" value="mypassword" />
        <param name="url" value="jdbc:cloudbees://cbdebate--1" />

        <!-- 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 (relevant part) web.xml (相关部分)

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

persistence.xml (relevant part) persistence.xml (相关部分)

        <persistence-unit name="debate" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/jdbc/debate</jta-data-source>

(... entity classes declaration ...)

        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
            <property name="hibernate.max_fetch_depth" value="5"/>
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
            <property name="org.hibernate.worker.batch_size" value="1000" />
        </properties>
        </persistence-unit>

Thank you in advance for any help 预先感谢您的任何帮助

Env : Jboss 7, JPA 2.0 环保:Jboss 7,JPA 2.0

Thanks to Nicolas' answer and some further googling, I managed to get it work. 多亏了尼古拉斯(Nicolas)的回答和进一步的谷歌搜索,我才设法使它生效。 As far as I understand, you cannot use the cloudbees driver com.cloudbees.jdbc.Driver from within a Jboss application (and specifically in our case on Cloudbees Java EE 6 server) and have to use the mysql one com.mysql.jdbc.Driver . 据我了解,您不能从Jboss应用程序(特别是在Cloudbees Java EE 6服务器上)中使用cloudbees驱动程序com.cloudbees.jdbc.Driver ,而必须使用mysql一个com.mysql.jdbc.Driver
As Nicolas stated the jdbc:cloudbees://[databaseName] database url uses by convention the cloudbees driver. 正如Nicolas所说, jdbc:cloudbees://[databaseName]数据库URL按照惯例使用cloudbees驱动程序。 You need to use the url referencing the actual database (you can find it in the cloudbees database configuration page) in the form of : 您需要以以下形式使用引用实际数据库的URL(可以在cloudbees数据库配置页面中找到它):

jdbc:mysql://ec2-AAA-BBB-CCC-DDD.compute-1.amazonaws.com:3306/[databaseName]

the important point here is the jdbc: mysql ://... 这里的重点是jdbc: mysql :// ...

Change the url of the database in cloudbees-web.xml using the form above and it works ! 使用上面的表格在cloudbees-web.xml中更改数据库的URL,它可以正常工作!

Maybe the cloudbees people could make the documentation a little bit clearer on this particular point 也许云蜂人可以在这一点上使文档更加清晰

To use jdbc:cloudbees:* JDBC URL you need to use com.cloudbees.jdbc.Driver as driver class name. 要使用jdbc:cloudbees:* JDBC URL,您需要使用com.cloudbees.jdbc.Driver作为驱动程序类名称。

by convention, each jdbc driver registered on a JVM uses a prefix before it's own specific url infos, so that a jdbc URL is "jdbc::" 按照约定,在JVM上注册的每个jdbc驱动程序在其自己的特定url信息之前均使用前缀,因此jdbc URL为“ jdbc ::”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Glassfish / Java EE6 / MySQL中的特殊字符问题 - Issue with special characters in Glassfish/Java EE6/MySQL 如何在Eclipse EE(Java)上配置mySQL - How to configure mySQL on Eclipse EE (Java) 无法在 Java EE 中使用 MySQL 和 TomEE 配置 Hibernate(错误的方言?) - Cannot configure Hibernate with MySQL and TomEE in Java EE (wrong dialect?) 如何在Bluemix上为MySQL配置云数据源? - How to configure cloud datasource for MySQL on Bluemix? 如何将Java EE应用程序迁移到rails - How to migrate Java EE application to rails 如何在Java EE Web应用程序的MYSQL中存储文件的物理文件位置? - How to store physical file location of files in MYSQL for a java EE web application? 独立的JAVA应用程序中的MySql池数据源(没有J2EE容器,没有JNDI,没有TOMCAT等) - MySql pooled datasource in standalone JAVA app (no J2EE container, no JNDI, no TOMCAT etc.) 服务器上如何托管Java EE应用程序 - how a java ee application is hosted on servers 使用MySQL的Java EE应用程序 - 我应该使用什么云服务? - Java EE Application with MySQL - What Cloud Service Shall I Use? 如何在将有效的Play应用程序部署到CloudBees时修复MySQL语法错误? - How to fix a MySQL syntax error when deploying a working Play application to CloudBees?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM