Hi all,
I’m trying to develop an application with EJB 3.0, JPA.
Somebody knows the way to define the user and password used to connect to the Database every time the Entity Manager is declared?
I need to use the login information from my application (user and password) to connect to the DB.
I’m using a code like this:
@Stateless
public class CustomerTaskImpl implements CustomerTask {
@PersistenceContext(name="OrderDB",
properties={
@PersistenceProperty(name="openjpa.ConnectionUserName", value="xxxxxx"),
@PersistenceProperty(name="openjpa.ConnectionPassword", value="yyyyyy")
}
)
EntityManager em;
public Customer findCustomer(int customerId) throws CustomerDoesNotExist
{
Customer customer = (Customer) em.find(Customer.class, customerId);
if (customer == null) {
throw new CustomerDoesNotExist("Customer does not exist");
}
return customer;
}
}
but the value for user and password must be a constant, and don’t work in every JDBC driver.
I would appreciate very much if somebody can tell me what I am trying to do is possible or not.