from:http://www.cnblogs.com/qwj888/p/3939768.html
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&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>
相关推荐
xa-data-source add --name=Mysql --jndi-name=java:jboss/datasources/NmsDmResourceDS --driver-name=mysql --xa-datasource-class=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource ``` 同样地,执行结果会显示...
- 按照提示新增 `Sybase jConnect for JDBC driver`,并在 `Library Paths` 中添加刚刚创建的 `SybjConnect45.jar` 文件。 - **重启JBuilder** 并配置项目属性: - 在 `Project Properties > Paths` 中,添加所需...
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <driver>oracle-driver</driver> <user-name>dw <password>dw <min-pool-size>10 <max-pool-size>100 <prefill>true <use-strict-min>...
这个文件定义了数据源(datasource),包括JNDI名称(MysqlDS)、连接URL(jdbc:mysql://localhost:3306/test)、驱动类(com.mysql.jdbc.Driver)、用户名(root)和密码(lishunli)。将这个配置文件放入JBoss的\...
<driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>root <password>root ``` **5. 持久化配置** 在项目的`persistence.xml`文件中,配置持久化单元(Persistence Unit),指定数据源和持久化...
<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/your_database?useSSL=false ...
- **JDBC Driver**:直接配置数据库驱动和连接信息。 - **JNDI DataSource**:通过JNDI名称来引用已配置的数据源,这种方式需要在应用服务器(如Weblogic)上定义数据源。 **3. 添加 jar 库文件** - **步骤**: ...
- Driver class: `com.mysql.jdbc.Driver` - Connection URL: `jdbc:mysql://localhost:3306/vane` - Username and Password: 根据实际设置输入。 2. **添加配置至Eclipse** 通过`Window` -> `Show View` -> `...
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.password">a123 <property name="hibernate.connection.url">jdbc:mysql://...
<property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/activiti"/> class="org.springframework.jdbc.datasource....