溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

JBoss中怎么配置MySQL數(shù)據(jù)源

發(fā)布時(shí)間:2021-08-13 16:32:03 來(lái)源:億速云 閱讀:184 作者:Leah 欄目:數(shù)據(jù)庫(kù)

JBoss中怎么配置MySQL數(shù)據(jù)源,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

JBOSS_HOME

 +- modules

     +- com

         +-

             +- main    

                 +- module.xml     

                 +- mysql-connector-java-5.1.15.jar   (mysql的jdbc驅(qū)動(dòng)jar文件,版本根據(jù)各自情況而定)

                 +- mysql-connector-java-5.1.15.jar.index

module.xml的?內(nèi)?容?如?下?:

例1. module.xml

<?xml version="1.0" encoding="UTF-8"?>

<module xmlns="urn:jboss:module:1.0" name="com.mysql">

  <resources>

    <resource-root path="mysql-connector-java-5.1.15.jar"/>

  </resources>

  <dependencies>

    <module name="javax.api"/>

  </dependencies>

</module>

mysql-connector-java-5.1.15.jar.index的?內(nèi)?容?如?下?:

例2. mysql-connector-java-5.1.15.jar.index

META-INF

META-INF/services

com

com/mysql

com/mysql/jdbc

com/mysql/jdbc/configs

com/mysql/jdbc/exceptions

com/mysql/jdbc/exceptions/jdbc4

com/mysql/jdbc/interceptors

com/mysql/jdbc/jdbc2

com/mysql/jdbc/jdbc2/optional

com/mysql/jdbc/jmx

com/mysql/jdbc/log

com/mysql/jdbc/profiler

com/mysql/jdbc/util

org

org/gjt

org/gjt/mm

org/gjt/mm/mysql

添?加?Server數(shù)?據(jù)?源?配?置?

AS7啟?動(dòng)?分?為?兩?種?形?式?,一?種?是?domain形?式?的?,一?種?是?standalone,這?里?我?們?選?擇?standalone。?

打?開(kāi)?JBOSS_HOME\standalone\configuration\standalone.xml文?件?,在?<datasources>下?添?加?如?下?內(nèi)?容?:

例3. mysql-connector-java-5.1.15.jar.index

<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">

                    <connection-url>

                        jdbc:mysql://192.168.1.150:3306/hospital?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8

                    </connection-url>

                    <driver>

                        com.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>

                        <use-strict-min>

                            false

                        </use-strict-min>

                        <flush-strategy>

                            FailingConnectionOnly

                        </flush-strategy>

                    </pool>

                    <security>

                        <user-name>

                            runes

                        </user-name>

                        <password>

                            runes

                        </password>

                    </security>

                    <statement>

                        <prepared-statement-cache-size>

                            32

                        </prepared-statement-cache-size>

                    </statement>

                </datasource>

例4. mysql-connector-java-5.1.15.jar.index

<driver name="com.mysql" module="com.mysql">

                        <xa-datasource-class>

                            com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

                        </xa-datasource-class>

                    </driver>

看完上述內(nèi)容,你們掌握J(rèn)Boss中怎么配置MySQL數(shù)據(jù)源的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI