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 を変更しました...なぜそれが機能するのかわかりません..しかし、機能します!!