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.