0

Jboss 7.1.1 を使用。localhost:9990/console から DB に接続しています。接続テストは正しいです。しかし、DBに何かを入れようとすると、例外が発生します:

Error creating Session: org.hibernate.HibernateException: Specified JDBC Driver com.mysql.jdbc.Driver class not found

私のhibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.password">root</property>
    <property   name="hibernate.connection.url">
     jdbc:mysql://localhost:3306/test</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">create</property>

     <mapping resource="MyApp/WebApp/model/Member.hbm.xml"/>
</session-factory>

私のセッション工場:

static
{
    try
    {
        Configuration configuration = new Configuration().configure();
        serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
        sessionFactory = configuration.buildSessionFactory(serviceRegistry);
    }
    catch (HibernateException he)
    {
        System.err.println("Error creating Session: " + he);
        throw new ExceptionInInitializerError(he);
    }

JBOSSHOME/modules/com/mysql/main 内には、module.xml とコネクタがあります。WEB-INFlib フォルダー内にコネクタを配置する必要はありません。

何か案は??

わかりました..私は解決策を見つけました。コネクタ jar を JBOSSHOME/modules/org/hibernate/main に置き、module.xml を変更しました...なぜそれが機能するのかわかりません..しかし、機能します!!

4

2 に答える 2

0

私のdomain.xml(またはstandalone.xml)の中に私はこれを持っています:

<datasource jta="true" jndi-name="java:jboss/Datasource" pool-name="MySqlDS" enabled="true" use-java-context="true" use-ccm="true">
    <connection-url>jdbc:mysql://localhost:3306/DBName</connection-url>
    <driver>com.mysql</driver>
    <security>
        <user-name>name</user-name>
        <password>pass</password>
    </security>
</datasource>
<drivers>
    <driver name="com.mysql"module="com.mysql">
    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
    </driver>
</drivers>

タグ内:

<subsystem xmlns="urn:jboss:domain:datasources:1.1">
于 2013-07-10T19:44:57.230 に答える