码迷,mamicode.com
首页 > 数据库 > 详细

Jboss wildfly add JDBC driver

时间:2014-08-27 18:02:58      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   java   使用   io   for   

Jboss wildfly  添加 JDBC driver

我这里使用的是 wildfly-8.0.0.Final 

第一步:

首先在modules里面添加mysql的驱动包

例如:modules\system\layers\base\com  在这下面新建 mysql文件夹,然后在mysql下面建子文件夹 main,这个main名字不能随便修改,这是规则。

整体路劲如下:

modules\system\layers\base\com\mysql\main

 

然后在main下面新建一个module.xml文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2011, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<!-- Represents the Hibernate 4.1.x (works with Hibernate 4.2.x jars also) module  -->
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-5.1.7-bin.jar"/>
        <!-- Insert resources here -->
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

name="com.mysql" 这个后面会用到,名字随便起,后面用的时候对应这个名字就行了

path="mysql-connector-java-5.1.7-bin.jar" 是mysql的驱动包
把mysql的驱动包拷到当前main目录下,注意path的名字要一样

第二步:
添加JNDI
我这里启动的是 standalone
打开standalone\configuration\standalone.xml 找到 drivers 节点 在里面添加一个driver 节点
如下:
<driver name="MySQLDSDriver" module="com.mysql">
                        <driver-class>com.mysql.jdbc.Driver</driver-class>
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>

这里的module 就是第一步建的module.xml里面的name 

然后找到datasources节点,在里面添加一个datasource 如下:

<datasource jndi-name="java:/MySQLDS" pool-name="MySQLDS" >
                    <connection-url>jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8</connection-url>
                    <driver>MySQLDSDriver</driver><!--对应上面的device name -->
                    <security>
                        <user-name>username</user-name>
                        <password>password</password>
                    </security>
                    <pool>
                        <min-pool-size>30</min-pool-size>
                        <max-pool-size>100</max-pool-size>
                        <prefill>true</prefill>
                    </pool>
                    <!--
                    <validation>
                        <validate-on-match>false</validate-on-match>
                        <background-validation>false</background-validation>
                    </validation>
                    <statement>
                        <share-prepared-statements>false</share-prepared-statements>
                    </statement>
                    -->
                </datasource>

 




Jboss wildfly add JDBC driver

标签:style   blog   http   color   os   java   使用   io   for   

原文地址:http://www.cnblogs.com/qwj888/p/3939768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!