使用しているHibernateバージョンは3.2.5です
これが私のcfg.xmlファイルの外観です。hibernate.connection.provider_classを使用して接続を取得しています。
<property name="hibernate.connection.provider_class">com.jdbc.ConnProvider</property>
<property name="hibernate.jdbc.batch_size">30</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.connection.release_mode">after_transaction</property>
<property name="hibernate.connection.autocommit">true</property>
<property name="hibernate.connection.pool_size">0</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
これはConnProviderクラスです。
package com.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import org.hibernate.HibernateException;
import org.hibernate.connection.ConnectionProvider;
/**
*
* @author gOMzY
*/
class ConnProvider implements ConnectionProvider {
@Override
public Connection getConnection() throws SQLException {
Connection conn = null;
try{
Class.forName("oracle.jdbc.OracleDriver");
conn=DriverManager.getConnection("<url>","<username>","<pwd>");
System.out.println("Connected!!!");
}catch(Exception e){
throw new UnsupportedOperationException("Not supported yet.");
}
return conn;
}
@Override
public void closeConnection(Connection cnctn) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean supportsAggressiveRelease() {
return false;
}
@Override
public void close() throws HibernateException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void configure(Properties prprts) throws HibernateException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
私が得ている例外:
重大:接続プロバイダーをインスタンス化できませんでしたjava.lang.IllegalAccessException:クラスorg.hibernate.connection.ConnectionProviderFactoryは、sun.reflect.Reflection.ensureMemberAccess(不明なソース)at java.lang.Class.newInstance0(Unknown Source)at java.lang.Class.newInstance(Unknown Source)at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:73)at org.hibernate.connection.ConnectionProviderFactory .newConnectionProvider(ConnectionProviderFactory.java:56)at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)atorg.hibernate.cfg。Configuration.buildSettings(Configuration.java:2009)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)at com.infy.jdbc.HibernateStartup.main(HibernateStartup.java:19)
この問題を解決する方法を提案してください。
よろしく、