gpt4 book ai didi

java - JBoss:无法连接到MySQL数据库

转载 作者:行者123 更新时间:2023-11-29 03:40:58 25 4
gpt4 key购买 nike

我正在运行 JBoss 作为独立版本。我想连接到我的本地 mysql 数据库

我复制了模块文件夹中的 mysql 连接器

me@air~/Downloads/jboss/standalone/configuration - 10:56:18  $ ls ../../modules/org/mysql/main/
mysql-connector-java-5.1.22-bin.jar

接下来我将 jboss/standalone/configuration 中的 standalone.xml 更改为

                <drivers>
<driver name="com.mysql" module="org.mysql" />
<driver name="h2" module="com.h2database.h2"> <!-- default provided-->
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>

然后我将数据源添加为

              <datasource jndi-name="java:/bb" pool-name="bb-pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/mydb</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>bb</user-name>
<password>bb</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>

我正在使用 JBoss AS 7.1。当我在控制台上启动服务器时,我看到错误

10:54:47,458 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:54:47,671 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/bb]

10:54:47,676 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
10:54:47,676 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2000ms - Started 134 of 212 services (2 services failed or missing dependencies, 74 services are passive or on-demand)

当我按下 Ctrl+C 时,我看到了

^C10:54:54,998 INFO  [org.jboss.as.osgi] (MSC service thread 1-8) JBAS011942: Stopping OSGi Framework
10:54:55,004 INFO [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
10:54:55,007 INFO [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService
10:54:55,008 INFO [com.arjuna.ats.jbossatx] ARJUNA032014: Stopping transaction recovery manager
10:54:55,010 INFO [org.apache.catalina.core.StandardContext] Container org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/] has not been started
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Pausing Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Stopping Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,043 INFO [org.jboss.as.controller] JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.jdbc-driver.mysql (new available)

10:54:55,044 INFO [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 47ms

我是 JBoss 的新手,不知道如何解决这个问题,也不知道我做错了什么

最佳答案

我认为在您的数据源中您引用了驱动程序 mysql,但您将驱动程序命名为 com.mysql

尝试将其中一个驱动程序名称更改为 mysql

请注意:最好使用 CLI 安装驱动程序并使用 CLI 或 Web 控制台构建数据源。 AS7 的目的是将这些工具用于您的所有配置,并且您应该自己接触 XML 的原因很少。

关于java - JBoss:无法连接到MySQL数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13978767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com