-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hibernate.connection.provider_class exception
PostPosted: Sat May 19, 2012 2:40 pm 
Newbie

Joined: Sat May 19, 2012 2:36 pm
Posts: 4
Hi all,

I hibernate version i am using is 3.2.5

This is how my cfg.xml file looks like, i am using hibernate.connection.provider_class to retrieve the connection:

Code:
<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>   


This is the ConnProvider class:

Code:
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.");
    }

}


The exception i am getting:

SEVERE: Could not instantiate connection provider java.lang.IllegalAccessException: Class org.hibernate.connection.ConnectionProviderFactory can not access a member of class com.infy.jdbc.ConnProvider with modifiers "" at sun.reflect.Reflection.ensureMemberAccess(Unknown Source) 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) at org.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)

Please suggest how to solve this issue.

Regards,


Top
 Profile  
 
 Post subject: Re: hibernate.connection.provider_class exception
PostPosted: Sat May 19, 2012 10:28 pm 
Newbie

Joined: Sat May 19, 2012 2:36 pm
Posts: 4
Hi all,

I changed the connProvider class visibility to public as shown below:
Code:
public class ConnProvider implements ConnectionProvider

and now i am getting this exception:
Code:
INFO: Initializing connection provider: com.jdbc.ConnProvider
java.lang.UnsupportedOperationException: Not supported yet.
   at com.infy.jdbc.ConnProvider.configure(ConnProvider.java:47)
   at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
   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)
   at org.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)


Please suggest

Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.