添加新的数据源(mysql)wildfly [英] Add new Datasource (mysql) wildfly

查看:162
本文介绍了添加新的数据源(mysql)wildfly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将新的数据源mysql jdbc驱动程序添加到我的wildfly服务器

I'm trying to add new datasource mysql jdbc driver to my wildfly server

我创建了文件夹wildfly.x.x.x/modules/system/layers/base/com/mysql/main 我在这里有jdbc jar文件和module.xml

I created folder wildfly.x.x.x/modules/system/layers/base/com/mysql/main I've got here jdbc jar file and module.xml

<module xmlns="urn:jboss:module:1.3" name="com.mysql">
        <resources>
         <resource-root path="mysql-connector-java-5.1.34-bin.jar"/>
     </resources>
     <dependencies>
      <module name="javax.api"/>
     </dependencies>
    </module>

然后将dataresource代码添加到standalone-full.xml中(在datareources标记下)

then added dataresource code into standalone-full.xml (under datareources tag)

 <datasource jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS"     enabled="true" use-java-context="true">
 <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
 <driver>MySQLDriver</driver>
<security>
 <user-name>root</user-name>
 <password></password>
</security>
</datasource>

但是当我转到Wildfly控制面板http://localhost:9990/console/时 dataresource没有出现,我错过了什么?

but when i go to wildfly control panel http://localhost:9990/console/ dataresource doesnt appear , what did i missed?

我也在尝试从界面手动添加它,但出现此错误

also i'm trying to add it manually from interface i'v got this error

Unexpected HTTP response: 500

Request
{
    "address" => [
        ("subsystem" => "datasources"),
        ("data-source" => "mysql")
    ],
    "operation" => "test-connection-in-pool"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid",
    "rolled-back" => true
} 

推荐答案

您是否添加了驱动程序定义?您的datasources子系统应如下所示:

Did you add a driver definition? Your datasources subsystem should look something like this:

    <subsystem xmlns="urn:jboss:domain:datasources:2.0">
        <datasources>
            <datasource jndi-name="java:/jdbc/myds" pool-name="myds" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost/mydb</connection-url>
                <driver>mysql</driver>
                <security>
                    <user-name>foo</user-name>
                    <password>bar</password>
                </security>
            </datasource>
            <drivers>
                <driver name="h2" module="com.h2database.h2">
                    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                </driver>
                <driver name="mysql" module="com.mysql">
                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

数据源定义中的driver元素必须按名称引用driver元素. module属性必须与您的MySQL驱动程序模块的名称匹配.

The driver element in the data source definition must reference a driver element by name. The module attribute must match the name of your MySQL driver module.

这篇关于添加新的数据源(mysql)wildfly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆