1

I am am tryign to access two dbs via one slsb, specifically one method within an slsb. However this is not possible ? Other than altering the stored procs is there anything else I could do ?

@PersistenceContext(unitName = "DB1")
private EntityManager oneEntityManager;

@PersistenceContext(unitName = "DB2")
private EntityManager twoEntityManager;

...


    StringBuilder queryString1 = new StringBuilder("exec myProc1 ");
    Query queryOne = oneEntityManager.createNativeQuery(queryString.toString());
    List<?> resultListOne = query.getResultList();

    StringBuilder queryString2 = new StringBuilder("exec myProc2 ");
    Query queryTwo = twoEntityManager.createNativeQuery(queryString2.toString());
    List<?> resultListTwo = queryTwo.getResultList();

...

causes : org.hibernate.exception.GenericJDBCException: Cannot open connection

4
  • 1
    And what is the "Caused by" part saying? Commented Jul 5, 2010 at 14:15
  • java : stateless session bean Commented Jul 5, 2010 at 14:19
  • javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629) Commented Jul 5, 2010 at 14:19
  • paste the whole stacktrace into your question. Commented Jul 5, 2010 at 14:23

1 Answer 1

1

I am am tryign to access two dbs via one slsb, specifically one method within an slsb. However this is not possible?

This is definitely possible but it would really help to give more details:

  • are you accessing different databases?
  • can you show the configuration of your persistence units?
  • can you tell us how your configured your datasource (XA?)
  • can you show how you annotated the method of your SLSB?

causes : org.hibernate.exception.GenericJDBCException: Cannot open connection

This suggests a configuration problem for one of your persistence unit but it's impossible to say more.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.