JPA - Is there a way/method to retrieve Persistence Unit information?

Java.sql. Connection connection = em. Unwrap(java.sql.Connection.

Class); Should work, what version are you using? Ensure that a transaction is active. To get the data source name you should be able to use, ((JNDIConnector)em.

Unwrap(JpaEntityManager. Class).getSession().getLogin().getConnector()).getName().

Here's what I've found helpful: private DataSource createDataSource() { ClientDataSource dataSource = new ClientDataSource(); dataSource. SetServerName("localhost"); dataSource. SetPortNumber(1527); dataSource.

SetDatabaseName("sample"); dataSource. SetUser("app"); dataSource. SetPassword("app"); return dataSource; } private EntityManagerFactory getEntityManagerFactory() { if (emf == null) { Map properties = new HashMap(); properties .

Put(PersistenceUnitProperties. NON_JTA_DATASOURCE,createDataSource()); emf = Persistence. CreateEntityManagerFactory(PU_NAME, properties); } return emf; } Can you create your datasource in the code, rather than configure via persistence.

Xml?

Thanks Kyle. I already created a persistence.xml. Is there a method something like: getEntityManger().

GetDataSourceName() in JPA/Eclipselink api? – neo May 18 at 14:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions