0

I'm trying to load a java program that is using Hibernate in an Oracle 12c database using loadjava. Right now Hibernate is using a configuration file to get its connection parameters (user, pass, driver, etc). Running the program in-database implies I have to use Oracle Default Connection instead of creating a new one using other parameters. How can I configure Hibernate to use the oracle default connection? Is it possible?

This is my actual hibernate configuration code that I'm trying to change:

        Configuration config = new Configuration();
config.setProperty("hibernate.connection.driver_class","oracle.jdbc.driver.OracleDriver");
        config.setProperty("hibernate.connection.username", dbusername);
        config.setProperty("hibernate.connection.password", dbpassword);
        config.setProperty("hibernate.connection.url", dburl);
        config.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect");    
        config.setProperty("hibernate.current_session_context_class", "managed");          
        config.setProperty("hibernate.show_sql", "false");        
        SessionFactory sessionFactory = config.buildSessionFactory();
        Session session = sessionFactory.openSession();

I need to replace this in order to use the Oracle default connection. I could revert to the standard jdbc connection using:

        OracleDriver ora = new OracleDriver(); 
        Connection conn = ora.defaultConnection(); 
        Statement stmt = conn.createStatement();

but this means changing a lot of code.

Thanks.

coni
  • 1
  • refer https://stackoverflow.com/questions/6074678/setting-properties-programmatically-in-hibernate – Gaurav Feb 13 '18 at 11:16
  • thanks, but the question is not how to set the properties, the question is what are the properties for using the default oracle connection, because the code is being executed inside the oracle database, so a connection is already available, I just have to say to Hibernate to use that connection. – coni Feb 13 '18 at 13:25

0 Answers0