我无法连接MySQL数据库WildFly - Hibernate

时间:2016-09-06 03:46:29

标签: mysql hibernate jpa jboss wildfly

我想用JSF制作一个简单的CRUD,我正在使用WildFly 9.0.2服务器。 我已经制作了standalone.xml和modules.xml配置,但我仍然有以下错误:

<datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jta="true" jndi-name="java:jboss/datasources/SiscosearchDS" pool-name="siscosearch" enabled="true" use-java-context="true" use-ccm="true">
                    <connection-url>jdbc:mysql://localhost:3306/siscosearch/</connection-url>                 
                    <driver>mysql</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <pool>
                        <min-pool-size>10</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                        <prefill>true</prefill>
                    </pool>
                    <security>
                        <user-name>root</user-name>
                        <password>admin</password>
                    </security>
                    <statement>
                        <prepared-statement-cache-size>32</prepared-statement-cache-size>
                        <share-prepared-statements>true</share-prepared-statements>
                    </statement>
                </datasource>
                <drivers>
                    <driver name="mysql" module="com.mysql">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

堆栈太大,无法在此处输入。

standalone.xml的数据源部分:

<persistence version="2.1"
   xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

<persistence-unit name="PERSISTENCE_UNIT" transaction-type="RESOURCE_LOCAL">

<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

<jta-data-source>java:jboss/datasources/SiscosearchDS</jta-data-source>

<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
</properties>
</persistence-unit>
</persistence>

和Persistence.XML:

# Handle key presses
def handle_input(key):
    with open('mobydick_ch1.txt') as f:
        lines = f.readlines()
        line_counter = 0
        if key == 'enter' or key == 'page down':
            text_box.base_widget.set_text(lines[line_counter])
            line_counter += 1
            main_loop.draw_screen()

        elif key == 'Q' or key == 'q':
            raise urwid.ExitMainLoop()

任何人都可以帮助我吗? 我尝试了一切。

1 个答案:

答案 0 :(得分:0)

我放弃使用WildFly,非常强大而且速度快,但配置起来却很难.. 现在我在我的项目中使用TomCat 9并且工作得很好。

谢谢你们,感谢您的贡献!