-->
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.  [ 1 post ] 
Author Message
 Post subject: How to inject JDBC connection
PostPosted: Fri Dec 19, 2008 4:01 am 
Newbie

Joined: Wed Feb 13, 2008 7:20 am
Posts: 1
Hi!
I have very simple question which demands very long answer:) I'm using EntityManagerFactory and EntityManager. Configuration is done in runtime with this method:

Code:
public static void init(LoginInfo info, String PU)
   {
      props.put("hibernate.connection.url", "jdbc:oracle:thin:@" + info.getDbLoginInfo().getConnString());
      LOG.debug(props);

      props.put("hibernate.connection.username", info.getDbLoginInfo().getUsername());
      props.put("hibernate.connection.password", info.getDbLoginInfo().getPassword());

      configuration.configure(PU, props);

      try
      {
         emf = configuration.buildEntityManagerFactory();

         LOG.debug("EntityManagerFactory opened.");
      }
      catch (RuntimeException e)
      {
         LOG.error("EntityManagerFactory not opened. " + e.getMessage());
      }
      if (Conf.SSO_TEST_MODE)
         System.out.println(props);
   }


Under certain condition this init method is not good. I got underlying jdbc connection and I must use it. How can I inject that connection to EntityManagerFactory.
I must also do some alter_session statements and those are done through jdbc connection, so this is another reason for that kind of approach.
Any ideas?
Thank you all very much for help.


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

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.