Reputation: 7426
I have two different applications( For eg. App1 and App2) deployed in glassfish. I want to use two different databases (For eg. DB1 and DB2) for those applications.
DB1 for App1 and DB2 for App2
. Is it possible?
If it is how can I configure this in Glassfish or Do I need to handle this in my code (I'm working in EJB3.0)?
Its urgent. Please reply asap.
Upvotes: 0
Views: 55
Reputation: 2321
In glassfish admin console create two jdbc resources (eg. jdbc/db1
and jdbc/db2
) with your db configurations. Then in your session bean inject db connection in this way:
@Resource(name = "jdbc/db1")
private DataSource ds;
However you can set your db configuration directly in the code by using @DataSourceDefinition
annotation.
Upvotes: 1